@@ -3,6 +3,8 @@ import * as assert from 'uvu/assert';
33import * as uvu from 'uvu' ;
44import { uneval , unflatten , parse , stringify } from '../index.js' ;
55
6+ globalThis . Temporal ??= ( await import ( '@js-temporal/polyfill' ) ) . Temporal ;
7+
68class Custom {
79 constructor ( value ) {
810 this . value = value ;
@@ -183,6 +185,69 @@ const fixtures = {
183185 value : new Uint16Array ( [ 10 , 20 , 30 , 40 ] ) . subarray ( 1 , 3 ) ,
184186 js : 'new Uint16Array([10,20,30,40]).subarray(1,3)' ,
185187 json : '[["Uint16Array",1,1,3],["ArrayBuffer","CgAUAB4AKAA="]]'
188+ } ,
189+ {
190+ name : 'Temporal.Duration' ,
191+ value : Temporal . Duration . from ( { years : 1 , months : 2 , days : 3 } ) ,
192+ js : 'Temporal.Duration.from("P1Y2M3D")' ,
193+ json : '[["Temporal.Duration","P1Y2M3D"]]'
194+ } ,
195+ {
196+ name : 'Temporal.Instant' ,
197+ value : Temporal . Instant . from ( '1999-09-29T05:30:00Z' ) ,
198+ js : 'Temporal.Instant.from("1999-09-29T05:30:00Z")' ,
199+ json : '[["Temporal.Instant","1999-09-29T05:30:00Z"]]'
200+ } ,
201+ {
202+ name : 'Temporal.PlainDate' ,
203+ value : Temporal . PlainDate . from ( { year : 1999 , month : 9 , day : 29 } ) ,
204+ js : 'Temporal.PlainDate.from("1999-09-29")' ,
205+ json : '[["Temporal.PlainDate","1999-09-29"]]'
206+ } ,
207+ {
208+ name : 'Temporal.PlainTime' ,
209+ value : Temporal . PlainTime . from ( { hour : 12 , minute : 34 , second : 56 } ) ,
210+ js : 'Temporal.PlainTime.from("12:34:56")' ,
211+ json : '[["Temporal.PlainTime","12:34:56"]]'
212+ } ,
213+ {
214+ name : 'Temporal.PlainDateTime' ,
215+ value : Temporal . PlainDateTime . from ( {
216+ year : 1999 ,
217+ month : 9 ,
218+ day : 29 ,
219+ hour : 12 ,
220+ minute : 34 ,
221+ second : 56
222+ } ) ,
223+ js : 'Temporal.PlainDateTime.from("1999-09-29T12:34:56")' ,
224+ json : '[["Temporal.PlainDateTime","1999-09-29T12:34:56"]]'
225+ } ,
226+ {
227+ name : 'Temporal.PlainMonthDay' ,
228+ value : Temporal . PlainMonthDay . from ( { month : 9 , day : 29 } ) ,
229+ js : 'Temporal.PlainMonthDay.from("09-29")' ,
230+ json : '[["Temporal.PlainMonthDay","09-29"]]'
231+ } ,
232+ {
233+ name : 'Temporal.PlainYearMonth' ,
234+ value : Temporal . PlainYearMonth . from ( { year : 1999 , month : 9 } ) ,
235+ js : 'Temporal.PlainYearMonth.from("1999-09")' ,
236+ json : '[["Temporal.PlainYearMonth","1999-09"]]'
237+ } ,
238+ {
239+ name : 'Temporal.ZonedDateTime' ,
240+ value : Temporal . ZonedDateTime . from ( {
241+ year : 1999 ,
242+ month : 9 ,
243+ day : 29 ,
244+ hour : 12 ,
245+ minute : 34 ,
246+ second : 56 ,
247+ timeZone : 'Europe/Rome'
248+ } ) ,
249+ js : 'Temporal.ZonedDateTime.from("1999-09-29T12:34:56+02:00[Europe/Rome]")' ,
250+ json : '[["Temporal.ZonedDateTime","1999-09-29T12:34:56+02:00[Europe/Rome]"]]'
186251 }
187252 ] ,
188253
0 commit comments