Skip to content

complete the chrono overloads - #51

Merged
mariusbancila merged 1 commit into
masterfrom
feature/chrono-overloads
Aug 12, 2026
Merged

complete the chrono overloads#51
mariusbancila merged 1 commit into
masterfrom
feature/chrono-overloads

Conversation

@mariusbancila

Copy link
Copy Markdown
Owner

The std::chrono overloads added in #39 turned a failed lookup into a real-looking timestamp. cron_next returns INVALID_TIME when an expression has no next occurrence - an expression whose years have all gone by, say - and the chrono wrapper passed that straight to from_time_t, yielding 1969-12-31 23:59:59. A caller had no way to tell that from a genuine answer.

They now return time_point::min(), matching how the other overloads already report it:

┌─────────────────────────┬────────────────────┐
│        Overload         │ Reports failure as │
├─────────────────────────┼────────────────────┤
│ std::time_t             │ INVALID_TIME       │
├─────────────────────────┼────────────────────┤
│ std::tm                 │ a zeroed std::tm   │
├─────────────────────────┼────────────────────┤
│ std::chrono::time_point │ time_point::min()  │
└─────────────────────────┴────────────────────┘

Both overloads are also templated on the duration now, so a caller working in milliseconds gets milliseconds back instead of the clock's default duration. Explicit traits still work, since Duration is deduced.

croncpp stays within C++11, so none of C++20's calendar or time zone facilities are used.

New test_chrono.cpp covering the three overloads agreeing on the same instant, the failure sentinel, duration round-tripping checked with static_assert, sub-second cron_next_ceil, and explicit traits.

Fixes #10.

@mariusbancila
mariusbancila merged commit f9bd0ca into master Aug 12, 2026
17 checks passed
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

Successfully merging this pull request may close these issues.

Support chrono

1 participant