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

croncpp returning time in the past near the DST #32

Open
enrico-samknows opened this issue Mar 28, 2023 · 1 comment
Open

croncpp returning time in the past near the DST #32

enrico-samknows opened this issue Mar 28, 2023 · 1 comment

Comments

@enrico-samknows
Copy link

Hi, I've found a strange case which fails:

#include "include/croncpp.h"
#include <iostream>

int main() {

   try {

     setenv("TZ", "CET-1CEST,M3.5.0,M10.5.0/3", 1);
     tzset();

     auto cron_string = std::string{ "30 55 5,11,17 * * *" };
     auto cron = cron::make_cron(cron_string);

     std::time_t now = 1679777644;
     std::time_t next = cron::cron_next(cron, now);

     std::cout << "Now:  " << now << std::endl;
     std::cout << "Next: " << next << std::endl;

  }
  catch (cron::bad_cronexpr const & ex)
  {
    std::cerr << ex.what() << '\n';
  }

}

prints:

Now:  1679777644
Next: 1679720130

where next < now.
Am I doing something wrong with the invocation here?
Thanks!

@enrico-samknows
Copy link
Author

FYI this doesn't happen if I always set date.tm_isdst = -1; before returning in add_to_field, set_field and reset_field. That's good enough for my usage but I think it has performance implications, so I'm not opening a PR.

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

No branches or pull requests

1 participant