-
-
Notifications
You must be signed in to change notification settings - Fork 158
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
Get summer/winter time from PHP timezone library #103
Conversation
Thanks for the PR! I think it is a good one, since it can now be used by other Holiday Providers as well. Always love a good refactor :) |
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.
You might want to run the code style script (composer php-cs-fixer
). That is why Travis failed :)
Can you also add a changelog entry?
$transition = array_shift($transitions); | ||
$dst = $transition['isdst']; | ||
|
||
foreach ($transitions as $transition) { |
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.
It seems you rely on the fact that the getTransitions
function returns the transitions sorted by time, correct? If returned randomly, I think getting the transitions for summer and wintertime then might not work this way.
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.
AFAICT from the PHP source code, we can rely on the dates being returned in chronological order. It seems the underlying data structure is also sorted by date.
Travis is happy now :-) |
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.
Perfect!
The date of transition to/from daylight saving time, and whether daylight saving time has been used at all, has changed over the years. This information is available in the tz (Olson) database that is included in PHP.
This PR makes Yasumi use the tz database for calculating the transitions. This works for any timezone that observes daylight saving time.
It seems that PHP currently only supports years until 2037 (when Unix timestamps exceed 31 bits), but this will likely be fixed in due time, if daylight saving time exists at all at that time.