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
Date helper datetime support #129
Date helper datetime support #129
Conversation
Thanks a lot for the PR! This is just the feedback for a quick glance over the code. I'll do a more thorough review later.
A cron expression, which runs every 5 minutes should also do so when DST changes. A cron expression running at 2:30 AM every day however should not. I'm thinking if it would therefore make sense to introduce an option argument where you could choose both, first or last. (Naming tbd) |
I've removed private as a dependency and reinstated the date type in Hmmm... ambiguous times are really a headache. I chose to return one of the instances is due to AWS EventBridge Scheduler's behavior. AWS' scheduer skips running when there's a gap, and runs only once when there's ambiguity. Nevertheless, you let me know how you'll like to proceed from here. We are getting closer to closing #69 and improving all crontab dependents :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmmm... ambiguous times are really a headache. I chose to return one of the instances is due to AWS EventBridge Scheduler's behavior. AWS' scheduer skips running when there's a gap, and runs only once when there's ambiguity.
I think we should let the user decide.
What do you think about adding on_ambiguous_time_trigger
to the CronExpression
struct? The values would be both
, earlier
, later
and default to later
.
Like this the user can decide how he wants to handle this edge-case.
We would then pass it through as an option in a keyword list to the DateHelper
.
Sounds good to me. Question then is: does that mean most functions in |
Probably not: If you have the setting on both, we can just return the first occurrence. When we look for the next candidate date, we should automatically reach the later occurrence. So the logic could be something like this:
|
I've addressed the issues in the review. I've also added targeted tests for I've not implement the ambiguous time handling yet, 'cos that depends on changes to |
5146102
to
fed56e9
Compare
@shaolang Do I understand correct that you want to send a secod PR for the ambiguity handling? |
Yes. Are you closing this PR prior to that? I'm okay with keep this or submitting a new PR. |
Separate work for me. But I‘ll merge directly onto Amazing work, thanks a lot for your efforts! |
@maennchen I've simplified
date_helper
with an extractedadd/3
function. As focus switches to testing that new function rigorously, I have to make it public during tests, I used PragDave's private library to keepadd/3
private in non-test environments,Functions in
date_helper
are now all able to do datetime arithmetic correctly, even for time gaps when daylight savings starts, and ambiguous times when daylight savings ends.One thing to note is that for ambiguous times when daylight saving ends, I've chosen to return the time with the standard timezone, e.g., between Eastern Daylight Time (EDT) and Eastern Standard Time (EST),
add/3
returns the time with EST. If you think it should return EDT instead, let me know, and I'll change it to that.Resolves #69