php / php/php-src

DateTimeZone->getTransitions can return first transition twice

Aperta
#18,051 0 commenti 0 reazioni 1 assegnatario Vedi su GitHub

@derickr ci sta già lavorando.

Dal 15/3/2025.

Bug Extension: date Status: Needs Triage
Lingua principale
C
Stelle
40.4k
Fork
8.1k
Merge medio
2g 13h
PR unite (30g)
96

Descrizione

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

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.