DST-related test failures in FilterDateTimeTest

Created on 8 November 2016, about 8 years ago
Updated 26 February 2023, almost 2 years ago

Problem/Motivation

See: https://www.drupal.org/pift-ci-job/523337

Note the time of the test run. It's displayed to me as:
Created November 5, 2016 - 04:02. jibran added test. Updated November 5, 2016 - 05:00.

My timezone is CST, which would make this 2:00a to 3:00a PST. When we add one day, as the test does, that's the official time when DST ended in the US.

From @jhedstrom:

the timezone for that test is set to `America/Vancouver`, so if they have daylight savings time, and the test was running at exactly the crossover, that could explain a failure...

This might be a bug that could occur only under rare circumstances, but whatever bug introduces test failures in HEAD at the least, and who knows what else could happen if there is an actual DST bug. So splitting the difference for issue priority at major, at least until we determine an underlying cause and whether it's related to DST or not.

2020
The America/Vancouver time zone changed from daylight savings to standard time at 2:00 AM on Sunday, Nov 1, 2020. The GMT offset is currently UTC/GMT -8 hours (PST).

https://www.drupal.org/pift-ci-job/1868691
Created 31 Oct 2020 at 10:32 CET. Krzysztof Domański added custom test. Updated 31 Oct 2020 at 11:27 CET.
https://www.drupal.org/pift-ci-job/1868692
Created 31 Oct 2020 at 10:32 CET. Krzysztof Domański added custom test. Updated 31 Oct 2020 at 11:27 CET.

timestamp, UTC, America/Vancouver
1604218500, 2020-11-01T07:15:00+00:00, 2020-11-01T00:15:00-07:00
1604222100, 2020-11-01T08:15:00+00:00, 2020-11-01T01:15:00-07:00
1604225700, 2020-11-01T09:15:00+00:00, 2020-11-01T01:15:00-07:00 // expected -08:00
1604229300, 2020-11-01T10:15:00+00:00, 2020-11-01T02:15:00-08:00
1604232900, 2020-11-01T11:15:00+00:00, 2020-11-01T03:15:00-08:00

Proposed resolution

Once a year, when the clock hand is moved backwards, it is not possible to distinguish between the first hour before (2020-11-01T01:15:00-07:00) and after (2020-11-01T01:15:00-07:00) the time change. The reason is a bug in PHP. See 🐛 DateTimePlus does not create dates with proper timestamps during DST transitions Needs work .

+    // Change variable $date, in the first hour after the time change. When you
+    // move the clock back, the time is the same again. However, it is treated
+    // as a date before the change. In such a situation, comparing it with the
+    // universal time ('UTC') causes errors.
+    // https://www.drupal.org/project/drupal/issues/2825845
+    $a = $formatter->format(static::$date, 'custom', DateTimeItemInterface::DATETIME_STORAGE_FORMAT, static::$timezone);
+    $b = $formatter->format(static::$date - 3600, 'custom', DateTimeItemInterface::DATETIME_STORAGE_FORMAT, static::$timezone);
+    if ($a == $b) {
+      static::$date -= 3600;
+    }

Remaining tasks

TBD

User interface changes

N/A

API changes

TBD

Data model changes

🐛 Bug report
Status

Needs work

Version

10.1

Component
Datetime 

Last updated 2 days ago

Created by

🇺🇸United States xjm

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024