@@ -526,45 +526,45 @@ public function getTestsForDump()
526
526
/**
527
527
* @dataProvider getTimestampTests
528
528
*/
529
- public function testParseTimestampAsUnixTimestampByDefault ($ yaml , $ year , $ month , $ day , $ hour , $ minute , $ second )
529
+ public function testParseTimestampAsUnixTimestampByDefault (string $ yaml , int $ year , int $ month , int $ day , int $ hour , int $ minute , int $ second )
530
530
{
531
531
$ this ->assertSame (gmmktime ($ hour , $ minute , $ second , $ month , $ day , $ year ), Inline::parse ($ yaml ));
532
532
}
533
533
534
534
/**
535
535
* @dataProvider getTimestampTests
536
536
*/
537
- public function testParseTimestampAsDateTimeObject ($ yaml , $ year , $ month , $ day , $ hour , $ minute , $ second , $ timezone )
537
+ public function testParseTimestampAsDateTimeObject (string $ yaml , int $ year , int $ month , int $ day , int $ hour , int $ minute , int $ second , int $ microsecond , string $ timezone )
538
538
{
539
539
$ expected = new \DateTime ($ yaml );
540
540
$ expected ->setTimeZone (new \DateTimeZone ('UTC ' ));
541
541
$ expected ->setDate ($ year , $ month , $ day );
542
- $ expected ->setTime ($ hour , $ minute , $ second , 1000000 * ( $ second - ( int ) $ second ) );
542
+ $ expected ->setTime ($ hour , $ minute , $ second , $ microsecond );
543
543
544
544
$ date = Inline::parse ($ yaml , Yaml::PARSE_DATETIME );
545
545
$ this ->assertEquals ($ expected , $ date );
546
546
$ this ->assertSame ($ timezone , $ date ->format ('O ' ));
547
547
}
548
548
549
- public function getTimestampTests ()
549
+ public function getTimestampTests (): array
550
550
{
551
551
return [
552
- 'canonical ' => ['2001-12-15T02:59:43.1Z ' , 2001 , 12 , 15 , 2 , 59 , 43.1 , '+0000 ' ],
553
- 'ISO-8601 ' => ['2001-12-15t21:59:43.10-05:00 ' , 2001 , 12 , 16 , 2 , 59 , 43.1 , '-0500 ' ],
554
- 'spaced ' => ['2001-12-15 21:59:43.10 -5 ' , 2001 , 12 , 16 , 2 , 59 , 43.1 , '-0500 ' ],
555
- 'date ' => ['2001-12-15 ' , 2001 , 12 , 15 , 0 , 0 , 0 , '+0000 ' ],
552
+ 'canonical ' => ['2001-12-15T02:59:43.1Z ' , 2001 , 12 , 15 , 2 , 59 , 43 , 100000 , '+0000 ' ],
553
+ 'ISO-8601 ' => ['2001-12-15t21:59:43.10-05:00 ' , 2001 , 12 , 16 , 2 , 59 , 43 , 100000 , '-0500 ' ],
554
+ 'spaced ' => ['2001-12-15 21:59:43.10 -5 ' , 2001 , 12 , 16 , 2 , 59 , 43 , 100000 , '-0500 ' ],
555
+ 'date ' => ['2001-12-15 ' , 2001 , 12 , 15 , 0 , 0 , 0 , 0 , '+0000 ' ],
556
556
];
557
557
}
558
558
559
559
/**
560
560
* @dataProvider getTimestampTests
561
561
*/
562
- public function testParseNestedTimestampListAsDateTimeObject ($ yaml , $ year , $ month , $ day , $ hour , $ minute , $ second )
562
+ public function testParseNestedTimestampListAsDateTimeObject (string $ yaml , int $ year , int $ month , int $ day , int $ hour , int $ minute , int $ second, int $ microsecond )
563
563
{
564
564
$ expected = new \DateTime ($ yaml );
565
565
$ expected ->setTimeZone (new \DateTimeZone ('UTC ' ));
566
566
$ expected ->setDate ($ year , $ month , $ day );
567
- $ expected ->setTime ($ hour , $ minute , $ second , 1000000 * ( $ second - ( int ) $ second ) );
567
+ $ expected ->setTime ($ hour , $ minute , $ second , $ microsecond );
568
568
569
569
$ expectedNested = ['nested ' => [$ expected ]];
570
570
$ yamlNested = "{nested: [ $ yaml]} " ;
0 commit comments