You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I don't get this to work properly across DST changes. It seems to me that this example converts to instant before adding the period, which means that the period is always from UTC and not local time.
Here we see that the result is the same UTC hour before before and after the recent DST change, which results in an incorrect local time for the second instant:
The problem seems to be that periodic-seq works with instants, but that the conversion to instant should instead be the final step. Not yet sure how to solve this in a nice way. A separate function for periodic-local-date-time-seq, and let the caller map to instants?
Or perhaps add an arity to periodic-seq for [LocalDateTime ZoneId duration-or-period] for calculating using LocalDateTimes, while still returning instants? (If so, maybe also include another arity for a final xform for doing complex schedules on the local date times, before returning the instants?)
In the mean time, here's a possible not-so-nice solution:
Hey @terjesb - I'm really sorry, this one slipped through my net 🤦
Absolutely agree - we prefer Instants when we actually come to scheduling the function, but if you're scheduling you may not want the same UTC time every day if you want it at 07:30 local. We could go for a separate arity, or maybe we could also accept java.time.Temporal as the first param (implemented by both Instant and ZDT), which should then return an object of the same type that the user passes in?
Thank you for this nice little library.
The README has an example of using periodic-seq for local times:
I don't get this to work properly across DST changes. It seems to me that this example converts to instant before adding the period, which means that the period is always from UTC and not local time.
This shows the problem:
Here we see that the result is the same UTC hour before before and after the recent DST change, which results in an incorrect local time for the second instant:
The problem seems to be that periodic-seq works with instants, but that the conversion to instant should instead be the final step. Not yet sure how to solve this in a nice way. A separate function for periodic-local-date-time-seq, and let the caller map to instants?
Or perhaps add an arity to periodic-seq for [LocalDateTime ZoneId duration-or-period] for calculating using LocalDateTimes, while still returning instants? (If so, maybe also include another arity for a final xform for doing complex schedules on the local date times, before returning the instants?)
In the mean time, here's a possible not-so-nice solution:
Here we see that the instants change as expected after DST change:
The text was updated successfully, but these errors were encountered: