@@ -558,9 +558,9 @@ describe('#integration temporal-types', () => {
558558
559559 it ( 'should convert Duration to ISO string' , ( ) => {
560560 expect ( duration ( 13 , 62 , 3 , 999111999 ) . toString ( ) ) . toEqual (
561- 'P13M62DT3 .999111999S'
561+ 'P1Y1M62DT3 .999111999S'
562562 )
563- expect ( duration ( 0 , 0 , 0 , 0 ) . toString ( ) ) . toEqual ( 'P0M0DT0S ' )
563+ expect ( duration ( 0 , 0 , 0 , 0 ) . toString ( ) ) . toEqual ( 'PT0S ' )
564564 expect ( duration ( - 1 , - 2 , 10 , 10 ) . toString ( ) ) . toEqual ( 'P-1M-2DT10.000000010S' )
565565 } , 90000 )
566566
@@ -713,114 +713,125 @@ describe('#integration temporal-types', () => {
713713 }
714714
715715 await testDurationToString ( [
716- { duration : duration ( 0 , 0 , 0 , 0 ) , expectedString : 'P0M0DT0S ' } ,
716+ { duration : duration ( 0 , 0 , 0 , 0 ) , expectedString : 'PT0S ' } ,
717717
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' } ,
722722
723723 {
724724 duration : duration ( 0 , 0 , 0 , 5 ) ,
725- expectedString : 'P0M0DT0 .000000005S'
725+ expectedString : 'PT0 .000000005S'
726726 } ,
727727 {
728728 duration : duration ( 0 , 0 , 0 , - 5 ) ,
729- expectedString : 'P0M0DT -0.000000005S'
729+ expectedString : 'PT -0.000000005S'
730730 } ,
731731 {
732732 duration : duration ( 0 , 0 , 0 , 999999999 ) ,
733- expectedString : 'P0M0DT0 .999999999S'
733+ expectedString : 'PT0 .999999999S'
734734 } ,
735735 {
736736 duration : duration ( 0 , 0 , 0 , - 999999999 ) ,
737- expectedString : 'P0M0DT -0.999999999S'
737+ expectedString : 'PT -0.999999999S'
738738 } ,
739739
740740 {
741741 duration : duration ( 0 , 0 , 1 , 5 ) ,
742- expectedString : 'P0M0DT1 .000000005S'
742+ expectedString : 'PT1 .000000005S'
743743 } ,
744744 {
745745 duration : duration ( 0 , 0 , - 1 , - 5 ) ,
746- expectedString : 'P0M0DT -1.000000005S'
746+ expectedString : 'PT -1.000000005S'
747747 } ,
748748 {
749749 duration : duration ( 0 , 0 , 1 , - 5 ) ,
750- expectedString : 'P0M0DT0 .999999995S'
750+ expectedString : 'PT0 .999999995S'
751751 } ,
752752 {
753753 duration : duration ( 0 , 0 , - 1 , 5 ) ,
754- expectedString : 'P0M0DT -0.999999995S'
754+ expectedString : 'PT -0.999999995S'
755755 } ,
756756 {
757757 duration : duration ( 0 , 0 , 1 , 999999999 ) ,
758- expectedString : 'P0M0DT1 .999999999S'
758+ expectedString : 'PT1 .999999999S'
759759 } ,
760760 {
761761 duration : duration ( 0 , 0 , - 1 , - 999999999 ) ,
762- expectedString : 'P0M0DT -1.999999999S'
762+ expectedString : 'PT -1.999999999S'
763763 } ,
764764 {
765765 duration : duration ( 0 , 0 , 1 , - 999999999 ) ,
766- expectedString : 'P0M0DT0 .000000001S'
766+ expectedString : 'PT0 .000000001S'
767767 } ,
768768 {
769769 duration : duration ( 0 , 0 , - 1 , 999999999 ) ,
770- expectedString : 'P0M0DT -0.000000001S'
770+ expectedString : 'PT -0.000000001S'
771771 } ,
772772
773773 {
774774 duration : duration ( 0 , 0 , 28 , 9 ) ,
775- expectedString : 'P0M0DT28 .000000009S'
775+ expectedString : 'PT28 .000000009S'
776776 } ,
777777 {
778778 duration : duration ( 0 , 0 , - 28 , 9 ) ,
779- expectedString : 'P0M0DT -27.999999991S'
779+ expectedString : 'PT -27.999999991S'
780780 } ,
781781 {
782782 duration : duration ( 0 , 0 , 28 , - 9 ) ,
783- expectedString : 'P0M0DT27 .999999991S'
783+ expectedString : 'PT27 .999999991S'
784784 } ,
785785 {
786786 duration : duration ( 0 , 0 , - 28 , - 9 ) ,
787- expectedString : 'P0M0DT -28.000000009S'
787+ expectedString : 'PT -28.000000009S'
788788 } ,
789789
790790 {
791791 duration : duration ( 0 , 0 , - 78036 , - 143000000 ) ,
792- expectedString : 'P0M0DT-78036 .143000000S'
792+ expectedString : 'PT-21H-40M-36 .143000000S'
793793 } ,
794794
795- { duration : duration ( 0 , 0 , 0 , 1000000000 ) , expectedString : 'P0M0DT1S ' } ,
795+ { duration : duration ( 0 , 0 , 0 , 1000000000 ) , expectedString : 'PT1S ' } ,
796796 {
797797 duration : duration ( 0 , 0 , 0 , - 1000000000 ) ,
798- expectedString : 'P0M0DT -1S'
798+ expectedString : 'PT -1S'
799799 } ,
800800 {
801801 duration : duration ( 0 , 0 , 0 , 1000000007 ) ,
802- expectedString : 'P0M0DT1 .000000007S'
802+ expectedString : 'PT1 .000000007S'
803803 } ,
804804 {
805805 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'
807819 } ,
808-
809820 {
810821 duration : duration ( 0 , 0 , 40 , 2123456789 ) ,
811- expectedString : 'P0M0DT42 .123456789S'
822+ expectedString : 'PT42 .123456789S'
812823 } ,
813824 {
814825 duration : duration ( 0 , 0 , - 40 , 2123456789 ) ,
815- expectedString : 'P0M0DT -37.876543211S'
826+ expectedString : 'PT -37.876543211S'
816827 } ,
817828 {
818829 duration : duration ( 0 , 0 , 40 , - 2123456789 ) ,
819- expectedString : 'P0M0DT37 .876543211S'
830+ expectedString : 'PT37 .876543211S'
820831 } ,
821832 {
822833 duration : duration ( 0 , 0 , - 40 , - 2123456789 ) ,
823- expectedString : 'P0M0DT -42.123456789S'
834+ expectedString : 'PT -42.123456789S'
824835 }
825836 ] )
826837 } , 90000 )
0 commit comments