Skip to content
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

Issue with timezones that have daylight savings time (DST) #3

Open
JorisH opened this issue Aug 7, 2024 · 0 comments
Open

Issue with timezones that have daylight savings time (DST) #3

JorisH opened this issue Aug 7, 2024 · 0 comments

Comments

@JorisH
Copy link
Member

JorisH commented Aug 7, 2024

Detailed description

When modifying a DateTimePlus (for example by adding days), the library is unable to consider DST because it is unaware of the timezone. The offset alone is not enough to identify the timezone and the need to adjust for DST.

Context

As we usually work in Europe/Brussels timezone - which has DST - we always will have this problem when modifying a DateTimePlus from summertime to wintertime and vice versa.

Possible implementation

Add a FormatWithTimezone that does what it says: include the timezone (iso the offset).

Your environment

how to reproduce:

// summertime ends at 27/10/2024 when 03:00 becomes 02:00
$summerTime = DateTimePlus::from("2024-10-27T00:00:00+02:00", FormatWithTimezone::ATOM);
// add 1 day
$winterTime = $summerTime->add(0, 0, 1); 
$winterFormatted = $winterTime->formatPlus("Y-MM-dd'T'HH:mm:ss.SSSZZZZZ'", 'nl_BE', new \DateTimeZone("Europe/Brussels"));

echo $winterFormatted;
// expected: 2024-10-28T00:00:00.000+01:00
// actual: 2024-10-27T23:00:00.000+01:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant