Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
Neverlord opened this issue May 16, 2024 Discussed in #1859 · 1 comment · Fixed by #1861
Closed

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

Neverlord opened this issue May 16, 2024 Discussed in #1859 · 1 comment · Fixed by #1861
Assignees
Labels
Milestone

Comments

@Neverlord
Copy link
Member

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

@Neverlord Neverlord added the bug label May 16, 2024
@Neverlord Neverlord self-assigned this May 16, 2024
@Neverlord
Copy link
Member Author

🤦‍♂️

@xliao-neology thanks for the bug report!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant