brick / date-time

Date and time library for PHP
MIT License
323 stars 29 forks source link

Minimal ZonedDateTime #33

Open repli2dev opened 3 years ago

repli2dev commented 3 years ago
var_dump(LocalDateTime::min()->getYear());
var_dump($a= ZonedDateTime::of(LocalDateTime::min(), TimeZone::utc())->getYear());

will yield

-999999
9999

Which is quite unexpected.

repli2dev commented 3 years ago

Moreover same problem with max()

var_dump(LocalDateTime::max()->getYear());
var_dump($a= ZonedDateTime::of(LocalDateTime::max(), TimeZone::utc())->getYear());
BenMorel commented 3 years ago

Hi, I can only reproduce the problem with max():

var_dump(LocalDateTime::min()->getYear());
var_dump(ZonedDateTime::of(LocalDateTime::min(), TimeZone::utc())->getYear());

var_dump(LocalDateTime::max()->getYear());
var_dump(ZonedDateTime::of(LocalDateTime::max(), TimeZone::utc())->getYear());
int(-999999)
int(-999999)
int(999999)
int(1999)
repli2dev commented 3 years ago

@BenMorel Speaking of the min()... There seem to be a difference in used PHP version: PHP 8.0 is OK, PHP 7.4 is NOK, PHP 7.2 is NOK...

BenMorel commented 3 years ago

I don't think it has to do with the PHP version, I get int(-999999) on PHP 7.3 and 7.4, too.

Thank you for the report anyway, I will look into it.

repli2dev commented 3 years ago

@BenMorel even more weird, just by switching PHP versions it got me the weird output. (PHP 8 and PHP 7.4 and PHP 7.2 installed via brew)... Also I have tested PHP 7.3 from MacOS and it is also NOK.

Could any extension cause this?