@@ -367,6 +367,9 @@ suite('duration', function () {
367
367
[ '-P55D' , [ - 1 , 'month' ] , { relativeTo : '2023-02-27T22:22:57Z' } ] ,
368
368
[ '-P65D' , [ - 3 , 'month' ] , { relativeTo : '2023-02-28T22:22:57Z' } ] ,
369
369
[ '-P75D' , [ - 3 , 'month' ] , { relativeTo : '2023-03-09T22:22:57Z' } ] ,
370
+ [ 'P1M' , [ 1 , 'month' ] , { relativeTo : '2024-05-31T00:00:00Z' } ] ,
371
+ [ '-P1M' , [ - 1 , 'month' ] , { relativeTo : '2024-05-31T00:00:00Z' } ] ,
372
+ [ '-P3M' , [ - 3 , 'month' ] , { relativeTo : '2023-05-30T00:00:00Z' } ] ,
370
373
[
371
374
'P8M' ,
372
375
[ 8 , 'month' ] ,
@@ -396,6 +399,8 @@ suite('duration', function () {
396
399
} ,
397
400
] ,
398
401
[ 'P1M1D' , [ 1 , 'month' ] , { relativeTo : new Date ( '2022-12-01T00:00:00Z' ) } ] ,
402
+ [ 'P1M1D' , [ 2 , 'month' ] , { relativeTo : new Date ( '2023-01-31T00:00:00Z' ) } ] ,
403
+ [ 'P1M30D' , [ 2 , 'month' ] , { relativeTo : new Date ( '2023-01-31T00:00:00Z' ) } ] ,
399
404
[
400
405
'P9M20DT25H' ,
401
406
[ 9 , 'month' ] ,
@@ -478,14 +483,14 @@ suite('duration', function () {
478
483
] ,
479
484
] )
480
485
for ( const [ input , [ val , unit ] , opts ] of relativeTests ) {
481
- test ( `getRelativeTimeUnit(${ input } ) === [${ val } , ${ unit } ]` , ( ) => {
486
+ test ( `getRelativeTimeUnit(${ input } ${ opts ? `, ${ JSON . stringify ( opts ) } ` : '' } ) === [${ val } , ${ unit } ]` , ( ) => {
482
487
assert . deepEqual (
483
488
getRelativeTimeUnit ( Duration . from ( input ) , opts || { relativeTo : new Date ( '2023-07-01T00:00:00' ) } ) ,
484
489
[ val , unit ] ,
485
490
)
486
491
} )
487
492
if ( opts ?. relativeTo ) continue
488
- test ( `getRelativeTimeUnit(-${ input } ) === [-${ val } , ${ unit } ]` , ( ) => {
493
+ test ( `getRelativeTimeUnit(-${ input } ${ opts ? `, ${ JSON . stringify ( opts ) } ` : '' } ) === [-${ val } , ${ unit } ]` , ( ) => {
489
494
assert . deepEqual (
490
495
getRelativeTimeUnit ( Duration . from ( `-${ input } ` ) , opts || { relativeTo : new Date ( '2023-07-01T00:00:00' ) } ) ,
491
496
[ - val , unit ] ,
0 commit comments