@@ -558,9 +558,9 @@ describe('#integration temporal-types', () => {
558
558
559
559
it ( 'should convert Duration to ISO string' , ( ) => {
560
560
expect ( duration ( 13 , 62 , 3 , 999111999 ) . toString ( ) ) . toEqual (
561
- 'P13M62DT3 .999111999S'
561
+ 'P1Y1M62DT3 .999111999S'
562
562
)
563
- expect ( duration ( 0 , 0 , 0 , 0 ) . toString ( ) ) . toEqual ( 'P0M0DT0S ' )
563
+ expect ( duration ( 0 , 0 , 0 , 0 ) . toString ( ) ) . toEqual ( 'PT0S ' )
564
564
expect ( duration ( - 1 , - 2 , 10 , 10 ) . toString ( ) ) . toEqual ( 'P-1M-2DT10.000000010S' )
565
565
} , 90000 )
566
566
@@ -713,114 +713,125 @@ describe('#integration temporal-types', () => {
713
713
}
714
714
715
715
await testDurationToString ( [
716
- { duration : duration ( 0 , 0 , 0 , 0 ) , expectedString : 'P0M0DT0S ' } ,
716
+ { duration : duration ( 0 , 0 , 0 , 0 ) , expectedString : 'PT0S ' } ,
717
717
718
- { duration : duration ( 0 , 0 , 42 , 0 ) , expectedString : 'P0M0DT42S ' } ,
719
- { duration : duration ( 0 , 0 , - 42 , 0 ) , expectedString : 'P0M0DT -42S' } ,
720
- { duration : duration ( 0 , 0 , 1 , 0 ) , expectedString : 'P0M0DT1S ' } ,
721
- { duration : duration ( 0 , 0 , - 1 , 0 ) , expectedString : 'P0M0DT -1S' } ,
718
+ { duration : duration ( 0 , 0 , 42 , 0 ) , expectedString : 'PT42S ' } ,
719
+ { duration : duration ( 0 , 0 , - 42 , 0 ) , expectedString : 'PT -42S' } ,
720
+ { duration : duration ( 0 , 0 , 1 , 0 ) , expectedString : 'PT1S ' } ,
721
+ { duration : duration ( 0 , 0 , - 1 , 0 ) , expectedString : 'PT -1S' } ,
722
722
723
723
{
724
724
duration : duration ( 0 , 0 , 0 , 5 ) ,
725
- expectedString : 'P0M0DT0 .000000005S'
725
+ expectedString : 'PT0 .000000005S'
726
726
} ,
727
727
{
728
728
duration : duration ( 0 , 0 , 0 , - 5 ) ,
729
- expectedString : 'P0M0DT -0.000000005S'
729
+ expectedString : 'PT -0.000000005S'
730
730
} ,
731
731
{
732
732
duration : duration ( 0 , 0 , 0 , 999999999 ) ,
733
- expectedString : 'P0M0DT0 .999999999S'
733
+ expectedString : 'PT0 .999999999S'
734
734
} ,
735
735
{
736
736
duration : duration ( 0 , 0 , 0 , - 999999999 ) ,
737
- expectedString : 'P0M0DT -0.999999999S'
737
+ expectedString : 'PT -0.999999999S'
738
738
} ,
739
739
740
740
{
741
741
duration : duration ( 0 , 0 , 1 , 5 ) ,
742
- expectedString : 'P0M0DT1 .000000005S'
742
+ expectedString : 'PT1 .000000005S'
743
743
} ,
744
744
{
745
745
duration : duration ( 0 , 0 , - 1 , - 5 ) ,
746
- expectedString : 'P0M0DT -1.000000005S'
746
+ expectedString : 'PT -1.000000005S'
747
747
} ,
748
748
{
749
749
duration : duration ( 0 , 0 , 1 , - 5 ) ,
750
- expectedString : 'P0M0DT0 .999999995S'
750
+ expectedString : 'PT0 .999999995S'
751
751
} ,
752
752
{
753
753
duration : duration ( 0 , 0 , - 1 , 5 ) ,
754
- expectedString : 'P0M0DT -0.999999995S'
754
+ expectedString : 'PT -0.999999995S'
755
755
} ,
756
756
{
757
757
duration : duration ( 0 , 0 , 1 , 999999999 ) ,
758
- expectedString : 'P0M0DT1 .999999999S'
758
+ expectedString : 'PT1 .999999999S'
759
759
} ,
760
760
{
761
761
duration : duration ( 0 , 0 , - 1 , - 999999999 ) ,
762
- expectedString : 'P0M0DT -1.999999999S'
762
+ expectedString : 'PT -1.999999999S'
763
763
} ,
764
764
{
765
765
duration : duration ( 0 , 0 , 1 , - 999999999 ) ,
766
- expectedString : 'P0M0DT0 .000000001S'
766
+ expectedString : 'PT0 .000000001S'
767
767
} ,
768
768
{
769
769
duration : duration ( 0 , 0 , - 1 , 999999999 ) ,
770
- expectedString : 'P0M0DT -0.000000001S'
770
+ expectedString : 'PT -0.000000001S'
771
771
} ,
772
772
773
773
{
774
774
duration : duration ( 0 , 0 , 28 , 9 ) ,
775
- expectedString : 'P0M0DT28 .000000009S'
775
+ expectedString : 'PT28 .000000009S'
776
776
} ,
777
777
{
778
778
duration : duration ( 0 , 0 , - 28 , 9 ) ,
779
- expectedString : 'P0M0DT -27.999999991S'
779
+ expectedString : 'PT -27.999999991S'
780
780
} ,
781
781
{
782
782
duration : duration ( 0 , 0 , 28 , - 9 ) ,
783
- expectedString : 'P0M0DT27 .999999991S'
783
+ expectedString : 'PT27 .999999991S'
784
784
} ,
785
785
{
786
786
duration : duration ( 0 , 0 , - 28 , - 9 ) ,
787
- expectedString : 'P0M0DT -28.000000009S'
787
+ expectedString : 'PT -28.000000009S'
788
788
} ,
789
789
790
790
{
791
791
duration : duration ( 0 , 0 , - 78036 , - 143000000 ) ,
792
- expectedString : 'P0M0DT-78036 .143000000S'
792
+ expectedString : 'PT-21H-40M-36 .143000000S'
793
793
} ,
794
794
795
- { duration : duration ( 0 , 0 , 0 , 1000000000 ) , expectedString : 'P0M0DT1S ' } ,
795
+ { duration : duration ( 0 , 0 , 0 , 1000000000 ) , expectedString : 'PT1S ' } ,
796
796
{
797
797
duration : duration ( 0 , 0 , 0 , - 1000000000 ) ,
798
- expectedString : 'P0M0DT -1S'
798
+ expectedString : 'PT -1S'
799
799
} ,
800
800
{
801
801
duration : duration ( 0 , 0 , 0 , 1000000007 ) ,
802
- expectedString : 'P0M0DT1 .000000007S'
802
+ expectedString : 'PT1 .000000007S'
803
803
} ,
804
804
{
805
805
duration : duration ( 0 , 0 , 0 , - 1000000007 ) ,
806
- expectedString : 'P0M0DT-1.000000007S'
806
+ expectedString : 'PT-1.000000007S'
807
+ } ,
808
+ {
809
+ duration : duration ( 0 , 0 , 1 , - 1000000007 ) ,
810
+ expectedString : 'PT-0.000000007S'
811
+ } ,
812
+ {
813
+ duration : duration ( 0 , 0 , - 60 , 1 ) ,
814
+ expectedString : 'PT-59.999999999S'
815
+ } ,
816
+ {
817
+ duration : duration ( 0 , 0 , - 60 , - 1 ) ,
818
+ expectedString : 'PT-1M-0.000000001S'
807
819
} ,
808
-
809
820
{
810
821
duration : duration ( 0 , 0 , 40 , 2123456789 ) ,
811
- expectedString : 'P0M0DT42 .123456789S'
822
+ expectedString : 'PT42 .123456789S'
812
823
} ,
813
824
{
814
825
duration : duration ( 0 , 0 , - 40 , 2123456789 ) ,
815
- expectedString : 'P0M0DT -37.876543211S'
826
+ expectedString : 'PT -37.876543211S'
816
827
} ,
817
828
{
818
829
duration : duration ( 0 , 0 , 40 , - 2123456789 ) ,
819
- expectedString : 'P0M0DT37 .876543211S'
830
+ expectedString : 'PT37 .876543211S'
820
831
} ,
821
832
{
822
833
duration : duration ( 0 , 0 , - 40 , - 2123456789 ) ,
823
- expectedString : 'P0M0DT -42.123456789S'
834
+ expectedString : 'PT -42.123456789S'
824
835
}
825
836
] )
826
837
} , 90000 )
0 commit comments