xref: /PHP-8.3/ext/date/tests/bug79580.phpt (revision 84266235)
1--TEST--
2Bug #79580: date_create_from_format misses leap year
3--FILE--
4<?php
5$tz = timezone_open( "UTC" );
6$values = [ "31 2020", "60 2020", "91 2020", "121 2020", "130 2020" ];
7
8foreach ( $values as $value )
9{
10	echo "Testing for {$value}: ";
11	$dt = DateTime::createFromFormat( 'z Y', $value );
12	if (!$dt) {
13		echo DateTime::getLastErrors()['errors'][0], "\n";
14	} else {
15		echo $dt->format('Y-m-d'), "\n";
16	}
17}
18?>
19--EXPECT--
20Testing for 31 2020: A 'day of year' can only come after a year has been found
21Testing for 60 2020: A 'day of year' can only come after a year has been found
22Testing for 91 2020: A 'day of year' can only come after a year has been found
23Testing for 121 2020: A 'day of year' can only come after a year has been found
24Testing for 130 2020: A 'day of year' can only come after a year has been found
25