Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
felixguendling committed Nov 24, 2024
1 parent 510190a commit a6fd963
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 37 deletions.
2 changes: 1 addition & 1 deletion .pkg
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
[adr]
[email protected]:triptix-tech/adr.git
branch=master
commit=bd3bb6bb8f1b5c0e066acd975767df27d5de22f8
commit=28365ed6b64b804296a09cb19cf8527247687f04
[googletest]
[email protected]:motis-project/googletest.git
branch=master
Expand Down
4 changes: 2 additions & 2 deletions .pkg.lock
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
5061172279391244024
18178785441693657313
cista 847b27100b7e730370b810ce62206a66b0bf2d79
zlib-ng 68ab3e2d80253ec5dc3c83691d9ff70477b32cd3
boost 930f38eb0365ceb7853273e03da4d9e7787abfb9
Expand Down Expand Up @@ -46,5 +46,5 @@ reflect-cpp c54fe66de4650b60c23aadd4a06d9db4ffeda22f
FTXUI dd6a5d371fd7a3e2937bb579955003c54b727233
tg 20c0f298b8ce58de29a790290f44dca7c4ecc364
utf8proc 779b780da3b99d123133eb99707b65c7e4324cc8
adr bd3bb6bb8f1b5c0e066acd975767df27d5de22f8
adr 28365ed6b64b804296a09cb19cf8527247687f04
openapi-cpp 6b5fd40a2b552fc5656aeff56f203a34c1d9e9af
3 changes: 0 additions & 3 deletions include/motis/parse_location.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@ namespace motis {
std::optional<osr::location> parse_location(std::string_view,
char separator = ',');

nigiri::unixtime_t get_date_time(std::optional<std::string> const& date = {},
std::optional<std::string> const& time = {});

date::sys_days parse_iso_date(std::string_view);

nigiri::routing::query cursor_to_query(std::string_view);
Expand Down
26 changes: 0 additions & 26 deletions src/parse_location.cc
Original file line number Diff line number Diff line change
Expand Up @@ -42,32 +42,6 @@ std::optional<osr::location> parse_location(std::string_view s,
return osr::location{pos, osr::level_t{level}};
}

n::unixtime_t get_date_time(std::optional<std::string> const& date,
std::optional<std::string> const& time) {
if (!date.has_value()) {
utl::verify(!time.has_value(), "time without date no supported");
return std::chrono::time_point_cast<n::i32_minutes>(
std::chrono::system_clock::now());
} else {
utl::verify(time.has_value(), "date without time not supported");
auto const date_time = *date + " " + *time;

// 06-28-2024 7:06pm
// 06-28-2024 19:06
std::stringstream ss;
ss << date_time;

auto t = n::unixtime_t{};
if (date_time.contains("AM") || date_time.contains("PM")) {
ss >> date::parse("%m-%d-%Y %I:%M %p", t);
} else {
ss >> date::parse("%m-%d-%Y %H:%M", t);
}

return t;
}
}

date::sys_days parse_iso_date(std::string_view s) {
auto d = date::sys_days{};
(std::stringstream{} << s) >> date::parse("%F", d);
Expand Down
5 changes: 0 additions & 5 deletions test/read_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,6 @@ TEST(motis, parse_location_no_level) {
EXPECT_EQ((osr::location{{-23.1, 45.2}, osr::level_t{0.F}}), *parsed);
}

TEST(motis, parse_date_time) {
auto const t = get_date_time("06-28-2024", "7:06 PM");
EXPECT_EQ(sys_days{2024_y / June / 28} + 19h + 6min, t);
}

TEST(motis, parse_cursor_earlier) {
auto const q = cursor_to_query("EARLIER|1720036560");

Expand Down

0 comments on commit a6fd963

Please sign in to comment.