@@ -35,6 +35,7 @@ const {
3535 ERR_INCOMPATIBLE_OPTION_PAIR ,
3636 ERR_INVALID_ARG_TYPE ,
3737 ERR_INVALID_ARG_VALUE ,
38+ ERR_NO_TEMPORAL ,
3839 ERR_OUT_OF_RANGE ,
3940 } ,
4041 hideStackFrames,
@@ -436,7 +437,18 @@ function nsFromTimeSpecBigInt(sec, nsec) {
436437 return sec * kNsPerSecBigInt + nsec ;
437438}
438439
440+ function instantFromNs ( nsec ) {
441+ if ( Temporal === undefined ) {
442+ throw new ERR_NO_TEMPORAL ( ) ;
443+ }
444+ // TODO(LiviaMedeiros): TemporalInstant primordial
445+ return new Temporal . Instant ( nsec ) ;
446+ }
447+
439448function instantFromTimeSpecMs ( msec , nsec ) {
449+ if ( Temporal === undefined ) {
450+ throw new ERR_NO_TEMPORAL ( ) ;
451+ }
440452 // TODO(LiviaMedeiros): TemporalInstant primordial
441453 return new Temporal . Instant ( BigInt ( MathFloor ( msec / kMsPerSec ) ) * kNsPerSecBigInt + BigInt ( nsec ) ) ;
442454}
@@ -556,7 +568,7 @@ const lazyTemporalBigIntFields = {
556568 enumerable : true ,
557569 configurable : true ,
558570 get ( ) {
559- return this . atimeInstant = new Temporal . Instant ( this . atimeNs ) ;
571+ return this . atimeInstant = instantFromNs ( this . atimeNs ) ;
560572 } ,
561573 set ( value ) {
562574 ObjectDefineProperty ( this , 'atimeInstant' , { __proto__ : null , value, writable : true } ) ;
@@ -567,7 +579,7 @@ const lazyTemporalBigIntFields = {
567579 enumerable : true ,
568580 configurable : true ,
569581 get ( ) {
570- return this . mtimeInstant = new Temporal . Instant ( this . mtimeNs ) ;
582+ return this . mtimeInstant = instantFromNs ( this . mtimeNs ) ;
571583 } ,
572584 set ( value ) {
573585 ObjectDefineProperty ( this , 'mtimeInstant' , { __proto__ : null , value, writable : true } ) ;
@@ -578,7 +590,7 @@ const lazyTemporalBigIntFields = {
578590 enumerable : true ,
579591 configurable : true ,
580592 get ( ) {
581- return this . ctimeInstant = new Temporal . Instant ( this . ctimeNs ) ;
593+ return this . ctimeInstant = instantFromNs ( this . ctimeNs ) ;
582594 } ,
583595 set ( value ) {
584596 ObjectDefineProperty ( this , 'ctimeInstant' , { __proto__ : null , value, writable : true } ) ;
@@ -589,7 +601,7 @@ const lazyTemporalBigIntFields = {
589601 enumerable : true ,
590602 configurable : true ,
591603 get ( ) {
592- return this . birthtimeInstant = new Temporal . Instant ( this . birthtimeNs ) ;
604+ return this . birthtimeInstant = instantFromNs ( this . birthtimeNs ) ;
593605 } ,
594606 set ( value ) {
595607 ObjectDefineProperty ( this , 'birthtimeInstant' , { __proto__ : null , value, writable : true } ) ;
0 commit comments