@@ -18,68 +18,6 @@ import * as Temporal from '@js-temporal/polyfill';
18
18
const { PlainDateTime } = Temporal ;
19
19
20
20
describe ( 'DateTime' , ( ) => {
21
- describe ( 'DateTime.toZonedDateTime()' , ( ) => {
22
- it ( 'works' , ( ) => {
23
- const dt = Temporal . PlainDateTime . from ( '2020-01-01T00:00' ) ;
24
- const zdt = dt . toZonedDateTime ( 'America/Los_Angeles' ) ;
25
- equal ( zdt . toString ( ) , '2020-01-01T00:00:00-08:00[America/Los_Angeles]' ) ;
26
- } ) ;
27
- it ( 'works with disambiguation option' , ( ) => {
28
- const dt = Temporal . PlainDateTime . from ( '2020-03-08T02:00' ) ;
29
- const zdt = dt . toZonedDateTime ( 'America/Los_Angeles' , { disambiguation : 'earlier' } ) ;
30
- equal ( zdt . toString ( ) , '2020-03-08T01:00:00-08:00[America/Los_Angeles]' ) ;
31
- } ) ;
32
- it ( 'datetime with multiple instants - Fall DST in Brazil' , ( ) => {
33
- const dt = PlainDateTime . from ( '2019-02-16T23:45' ) ;
34
- equal ( `${ dt . toZonedDateTime ( 'America/Sao_Paulo' ) } ` , '2019-02-16T23:45:00-02:00[America/Sao_Paulo]' ) ;
35
- equal (
36
- `${ dt . toZonedDateTime ( 'America/Sao_Paulo' , { disambiguation : 'compatible' } ) } ` ,
37
- '2019-02-16T23:45:00-02:00[America/Sao_Paulo]'
38
- ) ;
39
- equal (
40
- `${ dt . toZonedDateTime ( 'America/Sao_Paulo' , { disambiguation : 'earlier' } ) } ` ,
41
- '2019-02-16T23:45:00-02:00[America/Sao_Paulo]'
42
- ) ;
43
- equal (
44
- `${ dt . toZonedDateTime ( 'America/Sao_Paulo' , { disambiguation : 'later' } ) } ` ,
45
- '2019-02-16T23:45:00-03:00[America/Sao_Paulo]'
46
- ) ;
47
- throws ( ( ) => dt . toZonedDateTime ( 'America/Sao_Paulo' , { disambiguation : 'reject' } ) , RangeError ) ;
48
- } ) ;
49
- it ( 'datetime with multiple instants - Spring DST in Los Angeles' , ( ) => {
50
- const dt = PlainDateTime . from ( '2020-03-08T02:30' ) ;
51
- equal ( `${ dt . toZonedDateTime ( 'America/Los_Angeles' ) } ` , '2020-03-08T03:30:00-07:00[America/Los_Angeles]' ) ;
52
- equal (
53
- `${ dt . toZonedDateTime ( 'America/Los_Angeles' , { disambiguation : 'compatible' } ) } ` ,
54
- '2020-03-08T03:30:00-07:00[America/Los_Angeles]'
55
- ) ;
56
- equal (
57
- `${ dt . toZonedDateTime ( 'America/Los_Angeles' , { disambiguation : 'earlier' } ) } ` ,
58
- '2020-03-08T01:30:00-08:00[America/Los_Angeles]'
59
- ) ;
60
- equal (
61
- `${ dt . toZonedDateTime ( 'America/Los_Angeles' , { disambiguation : 'later' } ) } ` ,
62
- '2020-03-08T03:30:00-07:00[America/Los_Angeles]'
63
- ) ;
64
- throws ( ( ) => dt . toZonedDateTime ( 'America/Los_Angeles' , { disambiguation : 'reject' } ) , RangeError ) ;
65
- } ) ;
66
- it ( 'outside of Instant range' , ( ) => {
67
- const max = Temporal . PlainDateTime . from ( '+275760-09-13T23:59:59.999999999' ) ;
68
- throws ( ( ) => max . toZonedDateTime ( 'America/Godthab' ) , RangeError ) ;
69
- } ) ;
70
- it ( 'throws on bad disambiguation' , ( ) => {
71
- [ '' , 'EARLIER' , 'xyz' , 3 , null ] . forEach ( ( disambiguation ) =>
72
- throws ( ( ) => PlainDateTime . from ( '2019-10-29T10:46' ) . toZonedDateTime ( 'UTC' , { disambiguation } ) , RangeError )
73
- ) ;
74
- } ) ;
75
- it ( 'options may be a function object' , ( ) => {
76
- const dt = PlainDateTime . from ( '2019-10-29T10:46:38.271986102' ) ;
77
- equal (
78
- `${ dt . toZonedDateTime ( 'America/Sao_Paulo' , ( ) => { } ) } ` ,
79
- '2019-10-29T10:46:38.271986102-03:00[America/Sao_Paulo]'
80
- ) ;
81
- } ) ;
82
- } ) ;
83
21
describe ( 'Min/max range' , ( ) => {
84
22
it ( 'constructing from numbers' , ( ) => {
85
23
throws ( ( ) => new PlainDateTime ( - 271821 , 4 , 19 , 0 , 0 , 0 , 0 , 0 , 0 ) , RangeError ) ;
0 commit comments