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

DateTimeZone->getTransitions can return first transition twice #18051

Open
marc-mabe opened this issue Mar 13, 2025 · 0 comments
Open

DateTimeZone->getTransitions can return first transition twice #18051

marc-mabe opened this issue Mar 13, 2025 · 0 comments

Comments

@marc-mabe
Copy link
Contributor

Description

If timestamp_begin is the exact timestamp of an existing transition the transition will be included twice in the resulting array.

The following code:

<?php

$tzBln = new DateTimeZone('Europe/Berlin');
var_dump($tzBln->getTransitions(922582799, 941331599)); // works
var_dump($tzBln->getTransitions(922582800, 941331600)); // first transition reported twice
var_dump($tzBln->getTransitions(922582801, 941331601)); // works

Resulted in this output:

array(2) {
  [0]=>
  array(5) {
    ["ts"]=>
    int(922582799)
    ["time"]=>
    string(25) "1999-03-28T00:59:59+00:00"
    ["offset"]=>
    int(3600)
    ["isdst"]=>
    bool(false)
    ["abbr"]=>
    string(3) "CET"
  }
  [1]=>
  array(5) {
    ["ts"]=>
    int(922582800)
    ["time"]=>
    string(25) "1999-03-28T01:00:00+00:00"
    ["offset"]=>
    int(7200)
    ["isdst"]=>
    bool(true)
    ["abbr"]=>
    string(4) "CEST"
  }
}
array(3) {
  [0]=>
  array(5) {
    ["ts"]=>
    int(922582800)
    ["time"]=>
    string(25) "1999-03-28T01:00:00+00:00"
    ["offset"]=>
    int(7200)
    ["isdst"]=>
    bool(true)
    ["abbr"]=>
    string(4) "CEST"
  }
  [1]=>
  array(5) {
    ["ts"]=>
    int(922582800)
    ["time"]=>
    string(25) "1999-03-28T01:00:00+00:00"
    ["offset"]=>
    int(7200)
    ["isdst"]=>
    bool(true)
    ["abbr"]=>
    string(4) "CEST"
  }
  [2]=>
  array(5) {
    ["ts"]=>
    int(941331600)
    ["time"]=>
    string(25) "1999-10-31T01:00:00+00:00"
    ["offset"]=>
    int(3600)
    ["isdst"]=>
    bool(false)
    ["abbr"]=>
    string(3) "CET"
  }
}
array(2) {
  [0]=>
  array(5) {
    ["ts"]=>
    int(922582801)
    ["time"]=>
    string(25) "1999-03-28T01:00:01+00:00"
    ["offset"]=>
    int(7200)
    ["isdst"]=>
    bool(true)
    ["abbr"]=>
    string(4) "CEST"
  }
  [1]=>
  array(5) {
    ["ts"]=>
    int(941331600)
    ["time"]=>
    string(25) "1999-10-31T01:00:00+00:00"
    ["offset"]=>
    int(3600)
    ["isdst"]=>
    bool(false)
    ["abbr"]=>
    string(3) "CET"
  }
}

But I expected this output instead:

array(2) {
  [0]=>
  array(5) {
    ["ts"]=>
    int(922582799)
    ["time"]=>
    string(25) "1999-03-28T00:59:59+00:00"
    ["offset"]=>
    int(3600)
    ["isdst"]=>
    bool(false)
    ["abbr"]=>
    string(3) "CET"
  }
  [1]=>
  array(5) {
    ["ts"]=>
    int(922582800)
    ["time"]=>
    string(25) "1999-03-28T01:00:00+00:00"
    ["offset"]=>
    int(7200)
    ["isdst"]=>
    bool(true)
    ["abbr"]=>
    string(4) "CEST"
  }
}
array(2) {
  [0]=>
  array(5) {
    ["ts"]=>
    int(922582800)
    ["time"]=>
    string(25) "1999-03-28T01:00:00+00:00"
    ["offset"]=>
    int(7200)
    ["isdst"]=>
    bool(true)
    ["abbr"]=>
    string(4) "CEST"
  }
  [1]=>
  array(5) {
    ["ts"]=>
    int(941331600)
    ["time"]=>
    string(25) "1999-10-31T01:00:00+00:00"
    ["offset"]=>
    int(3600)
    ["isdst"]=>
    bool(false)
    ["abbr"]=>
    string(3) "CET"
  }
}
array(2) {
  [0]=>
  array(5) {
    ["ts"]=>
    int(922582801)
    ["time"]=>
    string(25) "1999-03-28T01:00:01+00:00"
    ["offset"]=>
    int(7200)
    ["isdst"]=>
    bool(true)
    ["abbr"]=>
    string(4) "CEST"
  }
  [1]=>
  array(5) {
    ["ts"]=>
    int(941331600)
    ["time"]=>
    string(25) "1999-10-31T01:00:00+00:00"
    ["offset"]=>
    int(3600)
    ["isdst"]=>
    bool(false)
    ["abbr"]=>
    string(3) "CET"
  }
}

PHP Version

PHP 8.x

Operating System

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants