Bug #68549 [Opn->Csd]: Timezones and offsets are not properly used when working with dates

From: Date: Fri, 20 May 2022 12:25:55 +0000
Subject: Bug #68549 [Opn->Csd]: Timezones and offsets are not properly used when working with dates
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-241551@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=68549&edit=1

 ID:                 68549
 Updated by:         git@php.net
 Reported by:        mfaust at usinternet dot com
 Summary:            Timezones and offsets are not properly used when
                     working with dates
-Status:             Open
+Status:             Closed
 Type:               Bug
 Package:            Date/time related
 Operating System:   Linux
 PHP Version:        5.6.3
 Block user comment: N
 Private report:     N

 New Comment:

Automatic comment on behalf of derickr
Revision: https://github.com/php/php-src/commit/20d8c1bea584aef6ec83417bea3a637d1e657ee6
Log: Fixed bug #68549 (Timezones and offsets are not properly used when working with dates)


Previous Comments:
------------------------------------------------------------------------
[2021-11-10 10:36:36] roel dot harbers at on2it dot net

I created a PR with a fix (for PHP7.4): https://github.com/php/php-src/pull/7639

------------------------------------------------------------------------
[2021-11-09 13:28:03] roel dot harbers at on2it dot net

sorry, the link misses the line number: https://github.com/php/php-src/blob/2b1b384d9a58aea734933ebcbc9ec2f1aa14b946/ext/date/lib/tm2unixtime.c#L391

------------------------------------------------------------------------
[2021-11-09 13:25:30] roel dot harbers at on2it dot net

I have added some unittests to clearly show the issue in https://github.com/php/php-src/pull/7636

It appears that PHP 8.1 *does* work correctly when using setTimezone (but not for
setTimestamp), while in PHP 7.4 neither works.

I tried to figure out how to fix it, and I've tracked it down to this: https://github.com/php/php-src/blob/2b1b384d9a58aea734933ebcbc9ec2f1aa14b946/ext/date/lib/tm2unixtime.c

It appears that this returns the *previous* timezone info. I'm struggling to fix it tho, with
how complex the code is.

------------------------------------------------------------------------
[2021-11-09 09:26:51] heiglandreas@php.net

It might indeed be the case that there are testcases already available.

------------------------------------------------------------------------
[2021-11-09 07:33:49] roel dot harbers at on2it dot net

Thanks for the reply :)

I'm looking at fixing it, and it seems there might already be test cases for it?

EXPECTED FAILED TEST SUMMARY
---------------------------------------------------------------------
DateTime::add() -- fall type2 type3 [ext/date/tests/DateTime_add-fall-type2-type3.phpt]  XFAIL
REASON: Various bugs exist
DateTime::add() -- fall type3 type2 [ext/date/tests/DateTime_add-fall-type3-type2.phpt]  XFAIL
REASON: Various bugs exist
DateTime::add() -- fall type3 type3 [ext/date/tests/DateTime_add-fall-type3-type3.phpt]  XFAIL
REASON: Various bugs exist
DateTime::add() -- spring type2 type3 [ext/date/tests/DateTime_add-spring-type2-type3.phpt]  XFAIL
REASON: Various bugs exist
DateTime::add() -- spring type3 type2 [ext/date/tests/DateTime_add-spring-type3-type2.phpt]  XFAIL
REASON: Various bugs exist
DateTime::add() -- spring type3 type3 [ext/date/tests/DateTime_add-spring-type3-type3.phpt]  XFAIL
REASON: Various bugs exist
DateTime::diff() -- fall type2 type3 [ext/date/tests/DateTime_diff-fall-type2-type3.phpt]  XFAIL
REASON: Various bugs exist
DateTime::diff() -- fall type3 type2 [ext/date/tests/DateTime_diff-fall-type3-type2.phpt]  XFAIL
REASON: Various bugs exist
DateTime::diff() -- fall type3 type3 [ext/date/tests/DateTime_diff-fall-type3-type3.phpt]  XFAIL
REASON: Various bugs exist
DateTime::diff() -- spring type2 type3 [ext/date/tests/DateTime_diff-spring-type2-type3.phpt]  XFAIL
REASON: Various bugs exist
DateTime::diff() -- spring type3 type2 [ext/date/tests/DateTime_diff-spring-type3-type2.phpt]  XFAIL
REASON: Various bugs exist
DateTime::diff() -- spring type3 type3 [ext/date/tests/DateTime_diff-spring-type3-type3.phpt]  XFAIL
REASON: Various bugs exist
DateTime::sub() -- fall type2 type3 [ext/date/tests/DateTime_sub-fall-type2-type3.phpt]  XFAIL
REASON: Various bugs exist
DateTime::sub() -- fall type3 type2 [ext/date/tests/DateTime_sub-fall-type3-type2.phpt]  XFAIL
REASON: Various bugs exist
DateTime::sub() -- fall type3 type3 [ext/date/tests/DateTime_sub-fall-type3-type3.phpt]  XFAIL
REASON: Various bugs exist
DateTime::sub() -- spring type2 type3 [ext/date/tests/DateTime_sub-spring-type2-type3.phpt]  XFAIL
REASON: Various bugs exist
DateTime::sub() -- spring type3 type2 [ext/date/tests/DateTime_sub-spring-type3-type2.phpt]  XFAIL
REASON: Various bugs exist
DateTime::sub() -- spring type3 type3 [ext/date/tests/DateTime_sub-spring-type3-type3.phpt]  XFAIL
REASON: Various bugs exist
Bug #52480 (Incorrect difference using DateInterval) [ext/date/tests/bug52480.phpt]  XFAIL REASON:
See https://bugs.php.net/bug.php?id=52480
RFC: DateTime and Daylight Saving Time Transitions (zone type 3, bd2)
[ext/date/tests/rfc-datetime_and_daylight_saving_time-type3-bd2.phpt]  XFAIL REASON: Still not quite
right
RFC: DateTime and Daylight Saving Time Transitions (zone type 3, fs)
[ext/date/tests/rfc-datetime_and_daylight_saving_time-type3-fs.phpt]  XFAIL REASON: Still not quite
right
=====================================================================

(on branch PHP-7.4)

------------------------------------------------------------------------


The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at

    https://bugs.php.net/bug.php?id=68549


--
Edit this bug report at https://bugs.php.net/bug.php?id=68549&edit=1


Thread (12 messages)

« previous php.bugs (#241551) next »