Skip to content

bug in chrono.cpp/ chrono.test.cpp? #1860

Description

@Neverlord

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Fields

No fields configured for Bug.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions