File tree 1 file changed +12
-1
lines changed
1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -400,11 +400,22 @@ export const crossPlatformPerformance: CrossPlatformPerformance = (() => {
400
400
return getGlobalObject < Window > ( ) . performance || performanceFallback ;
401
401
} ) ( ) ;
402
402
403
+ let FIRST_CLOCK_READ : number | undefined ;
404
+
405
+ /**
406
+ * This returns a timestamp of the first time we look at the clock
407
+ */
408
+ function getFirstClockRead ( ) : number {
409
+ if ( ! FIRST_CLOCK_READ ) {
410
+ FIRST_CLOCK_READ = crossPlatformPerformance . timeOrigin ;
411
+ }
412
+ return FIRST_CLOCK_READ ;
413
+ }
403
414
/**
404
415
* Returns a timestamp in seconds with milliseconds precision since the UNIX epoch calculated with the monotonic clock.
405
416
*/
406
417
export function timestampWithMs ( ) : number {
407
- return ( crossPlatformPerformance . timeOrigin + crossPlatformPerformance . now ( ) ) / 1000 ;
418
+ return ( getFirstClockRead ( ) + crossPlatformPerformance . now ( ) ) / 1000 ;
408
419
}
409
420
410
421
// https://semver.org/#is-there-a-suggested-regular-expression-regex-to-check-a-semver-string
You can’t perform that action at this time.
0 commit comments