tplaner / When

PHP Date Recursion library
https://github.com/tplaner/When
MIT License
513 stars 96 forks source link

Normalize dates when comparing for a monthly frequency (fixes #71) #72

Closed akf closed 5 years ago

akf commented 5 years ago

This modifies a comparison in occursOn for determining whether a monthly frequency (with interval > 1) is met. Both the start date and the date being compared are normalized to the first of the month, and to UTC. This ensures that we're looking at the number of months between the month part of the date. (As a specific example, comparing April 1 2019 to January 1 2019 produced a date diff just a little less than 3 months when comparing dates in the America/New_York time zone, because of the switch to daylight savings time that stole an hour between them.)

This corrects the occurrences produced for some "quarterly" meetings; the example used in the tests is "Every three months, first Monday of the month, starting January 7 2019."

tplaner commented 5 years ago

Excellent, thanks!