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