Closed (fixed)
Project:
Recurring Time Period
Version:
8.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
28 Sep 2017 at 10:04 UTC
Updated:
20 Oct 2017 at 14:19 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
erik.erskine commentedI'm not sure this will work - doing any kind of add/subtract on a date is dependent on timezone.
One example is with intervals that span a change in daylight savings time. For example, "2017-10-28 12:00 Europe/London" + "1 day" should result in "2017-10-29 12:00 Europe/London". In this instance the interval of 1 day is actually 23 hours because of the change in DST. But we only know this by having the timezone available along with the start date.
I think this can be avoided by making the plugin timezone agnostic, by changing
RecurringPeriodInterface::calculateDateto operate on\DateTimeobjects rather than timestamps. We can then always using theadd(\DateInterval $interval)function.Comment #3
joachim commented> For example, "2017-10-28 12:00 Europe/London" + "1 day" should result in "2017-10-29 12:00 Europe/London"
I've been racking my brains trying to think of a case where timezone would affect the result, as I had a feeling it would, but couldn't think of one! :) Thanks!
> by changing RecurringPeriodInterface::calculateDate to operate on \DateTime objects rather than timestamps. We can then always using the add(\DateInterval $interval) function.
That's handing over responsibility to the caller, which has the same decision to make...
In the case of something like a license, users expect the license to work in their own timezone, set by their personal settings... which this module can't know about, so yes, I guess changing to DateTime objects works, and the calling module has to decide what to do.
This responsibility will need documenting.
Comment #4
erik.erskine commentedPatch included. This uses
\DateTimeImmutablerather than\DateTimeto avoid plugins modifying the passed-in values.Comment #5
joachim commentedCommitted with some documentation and code formatting tweaks.
Thanks!