Discussed in #1859
Originally posted by xliao-neology May 15, 2024
auto str1 = chrono::to_string(make_timestamp());
std::cout << str1 << std::endl;
auto to_utc = [](std::string_view str) {
return caf::chrono::datetime::from_string(str).and_then([](auto&& dt) {
auto cpy = dt;
cpy.force_utc();
return expected<std::string>{to_string(cpy)};
});
};
auto str = chrono::to_string(std::chrono::system_clock::now());
std::cout<<*to_utc(str)<<std::endl;
2024-05-15T14:36:28.710562027-05:00
2024-05-15T09:36:28.710635744Z
I use central time which is 5hours behind UTC, the first output seems correct(14:36:28.710562027 is my local time), but when I call to_utc from chrono.test.cpp, the output is not the correct UTC time, it should be add the offset instead of of subtract it .
correct UTC time should be
2024-05-15T19:36:28.710635744Z
Discussed in #1859
Originally posted by xliao-neology May 15, 2024
I use central time which is 5hours behind UTC, the first output seems correct(14:36:28.710562027 is my local time), but when I call to_utc from chrono.test.cpp, the output is not the correct UTC time, it should be add the offset instead of of subtract it .
correct UTC time should be
2024-05-15T19:36:28.710635744Z