@@ -24,8 +24,8 @@ use boa_gc::{Finalize, Trace};
24
24
use boa_profiler:: Profiler ;
25
25
use num_traits:: ToPrimitive ;
26
26
use temporal_rs:: {
27
- components:: Instant as InnerInstant ,
28
27
options:: { RoundingIncrement , RoundingOptions , TemporalRoundingMode } ,
28
+ Instant as InnerInstant ,
29
29
} ;
30
30
31
31
use super :: options:: get_difference_settings;
@@ -46,19 +46,19 @@ impl IntrinsicObject for Instant {
46
46
fn init ( realm : & Realm ) {
47
47
let _timer = Profiler :: global ( ) . start_event ( std:: any:: type_name :: < Self > ( ) , "init" ) ;
48
48
49
- let get_seconds = BuiltInBuilder :: callable ( realm, Self :: get_epoc_seconds )
49
+ let get_seconds = BuiltInBuilder :: callable ( realm, Self :: get_epoch_seconds )
50
50
. name ( js_string ! ( "get epochSeconds" ) )
51
51
. build ( ) ;
52
52
53
- let get_millis = BuiltInBuilder :: callable ( realm, Self :: get_epoc_milliseconds )
53
+ let get_millis = BuiltInBuilder :: callable ( realm, Self :: get_epoch_milliseconds )
54
54
. name ( js_string ! ( "get epochMilliseconds" ) )
55
55
. build ( ) ;
56
56
57
- let get_micros = BuiltInBuilder :: callable ( realm, Self :: get_epoc_microseconds )
57
+ let get_micros = BuiltInBuilder :: callable ( realm, Self :: get_epoch_microseconds )
58
58
. name ( js_string ! ( "get epochMicroseconds" ) )
59
59
. build ( ) ;
60
60
61
- let get_nanos = BuiltInBuilder :: callable ( realm, Self :: get_epoc_nanoseconds )
61
+ let get_nanos = BuiltInBuilder :: callable ( realm, Self :: get_epoch_nanoseconds )
62
62
. name ( js_string ! ( "get epochNanoseconds" ) )
63
63
. build ( ) ;
64
64
@@ -150,7 +150,7 @@ impl BuiltInConstructor for Instant {
150
150
151
151
// 3. If ! IsValidEpochNanoseconds(epochNanoseconds) is false, throw a RangeError exception.
152
152
// NOTE: temporal_rs::Instant asserts that the epochNanoseconds are valid.
153
- let instant = InnerInstant :: new ( epoch_nanos. as_inner ( ) . to_i128 ( ) . unwrap_or ( i128:: MAX ) ) ?;
153
+ let instant = InnerInstant :: try_new ( epoch_nanos. as_inner ( ) . to_i128 ( ) . unwrap_or ( i128:: MAX ) ) ?;
154
154
// 4. Return ? CreateTemporalInstant(epochNanoseconds, NewTarget).
155
155
create_temporal_instant ( instant, Some ( new_target. clone ( ) ) , context)
156
156
}
@@ -201,7 +201,7 @@ impl Instant {
201
201
// 3. Return ! CreateTemporalInstant(epochNanoseconds).
202
202
let nanos = epoch_nanos. as_inner ( ) . to_i128 ( ) ;
203
203
create_temporal_instant (
204
- InnerInstant :: new ( nanos. unwrap_or ( i128:: MAX ) ) ?,
204
+ InnerInstant :: try_new ( nanos. unwrap_or ( i128:: MAX ) ) ?,
205
205
None ,
206
206
context,
207
207
)
@@ -226,7 +226,7 @@ impl Instant {
226
226
227
227
impl Instant {
228
228
/// 8.3.3 get Temporal.Instant.prototype.epochSeconds
229
- pub ( crate ) fn get_epoc_seconds (
229
+ pub ( crate ) fn get_epoch_seconds (
230
230
this : & JsValue ,
231
231
_: & [ JsValue ] ,
232
232
_: & mut Context ,
@@ -240,11 +240,11 @@ impl Instant {
240
240
JsNativeError :: typ ( ) . with_message ( "the this object must be an instant object." )
241
241
} ) ?;
242
242
// 3. Let ns be instant.[[Nanoseconds]].
243
- Ok ( instant. inner . epoch_seconds ( ) . into ( ) )
243
+ Ok ( JsBigInt :: from ( instant. inner . epoch_seconds ( ) ) . into ( ) )
244
244
}
245
245
246
246
/// 8.3.4 get Temporal.Instant.prototype.epochMilliseconds
247
- pub ( crate ) fn get_epoc_milliseconds (
247
+ pub ( crate ) fn get_epoch_milliseconds (
248
248
this : & JsValue ,
249
249
_: & [ JsValue ] ,
250
250
_: & mut Context ,
@@ -260,11 +260,11 @@ impl Instant {
260
260
// 3. Let ns be instant.[[Nanoseconds]].
261
261
// 4. Let ms be floor(ℝ(ns) / 106).
262
262
// 5. Return 𝔽(ms).
263
- Ok ( instant. inner . epoch_milliseconds ( ) . into ( ) )
263
+ Ok ( JsBigInt :: from ( instant. inner . epoch_milliseconds ( ) ) . into ( ) )
264
264
}
265
265
266
266
/// 8.3.5 get Temporal.Instant.prototype.epochMicroseconds
267
- pub ( crate ) fn get_epoc_microseconds (
267
+ pub ( crate ) fn get_epoch_microseconds (
268
268
this : & JsValue ,
269
269
_: & [ JsValue ] ,
270
270
_: & mut Context ,
@@ -280,13 +280,11 @@ impl Instant {
280
280
// 3. Let ns be instant.[[Nanoseconds]].
281
281
// 4. Let µs be floor(ℝ(ns) / 103).
282
282
// 5. Return ℤ(µs).
283
- let big_int = JsBigInt :: try_from ( instant. inner . epoch_microseconds ( ) )
284
- . expect ( "valid microseconds is in range of BigInt" ) ;
285
- Ok ( big_int. into ( ) )
283
+ Ok ( JsBigInt :: from ( instant. inner . epoch_microseconds ( ) ) . into ( ) )
286
284
}
287
285
288
286
/// 8.3.6 get Temporal.Instant.prototype.epochNanoseconds
289
- pub ( crate ) fn get_epoc_nanoseconds (
287
+ pub ( crate ) fn get_epoch_nanoseconds (
290
288
this : & JsValue ,
291
289
_: & [ JsValue ] ,
292
290
_: & mut Context ,
@@ -301,9 +299,7 @@ impl Instant {
301
299
} ) ?;
302
300
// 3. Let ns be instant.[[Nanoseconds]].
303
301
// 4. Return ns.
304
- let big_int = JsBigInt :: try_from ( instant. inner . epoch_nanoseconds ( ) )
305
- . expect ( "valid nanoseconds is in range of BigInt" ) ;
306
- Ok ( big_int. into ( ) )
302
+ Ok ( JsBigInt :: from ( instant. inner . epoch_nanoseconds ( ) ) . into ( ) )
307
303
}
308
304
309
305
/// 8.3.7 `Temporal.Instant.prototype.add ( temporalDurationLike )`
0 commit comments