Observed
With scnlib 4.0.1:
#include <chrono>
#include <fmt/chrono.h>
#include <iostream>
#include <scn/scan.h>
#include <scn/chrono.h>
int main() {
const auto datetime = std::string_view("2025-02-05T16:00:01");
using Time = std::chrono::sys_time<std::chrono::seconds>;
Time tp;
auto is = std::istringstream(std::string(datetime));
is >> std::chrono::parse("%Y-%m-%dT%H:%M:%S", tp);
if (is.fail()) { return 1; }
std::cout << fmt::format("{0:%F}T{0:%T}\n", tp);
std::cout << tp.time_since_epoch().count() << std::endl;
auto result = scn::scan<Time>(datetime, "{:%Y-%m-%dT%H:%M:%S}");
if (!result) { return 2; }
std::cout << fmt::format("{0:%F}T{0:%T}\n", result->value());
std::cout << result->value().time_since_epoch().count() << std::endl;
return 0;
}
Run with TZ=America/New_York in the environment variables.
Output:
2025-02-05T16:00:01
1738771201
2025-02-05T21:00:01
1738789201
https://godbolt.org/z/E7e63G8bn
Expected
Parsing to not be dependent on local time zone, unless explicitly specified somehow.
Observed
With scnlib 4.0.1:
Run with
TZ=America/New_Yorkin the environment variables.Output:
https://godbolt.org/z/E7e63G8bn
Expected
Parsing to not be dependent on local time zone, unless explicitly specified somehow.