date-time icon indicating copy to clipboard operation
date-time copied to clipboard

Minimal ZonedDateTime

Open repli2dev opened this issue 3 years ago • 5 comments

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

will yield

-999999
9999

Which is quite unexpected.

repli2dev avatar Mar 10 '21 12:03 repli2dev

Moreover same problem with max()

var_dump(LocalDateTime::max()->getYear());
var_dump($a= ZonedDateTime::of(LocalDateTime::max(), TimeZone::utc())->getYear());

repli2dev avatar Mar 10 '21 13:03 repli2dev

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)

BenMorel avatar Mar 13 '21 12:03 BenMorel

@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...

repli2dev avatar Mar 17 '21 11:03 repli2dev

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.

BenMorel avatar Mar 18 '21 10:03 BenMorel

@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?

repli2dev avatar Mar 18 '21 10:03 repli2dev