mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-26 16:22:07 +00:00 
			
		
		
		
	 39cdffd78d
			
		
	
	
		39cdffd78d
		
	
	
	
	
		
			
			It is defined as follows:
    21.4.3.1 Date.now ( )
    https://tc39.es/ecma262/#sec-date.now
    The now function returns the time value designating the UTC date and
    time of the occurrence of the call to now.
"Time value" is defined as:
    21.4.1.1 Time Values and Time Range
    https://tc39.es/ecma262/#sec-time-values-and-time-range
    An ECMAScript time value is a Number, either a finite integral
    Number representing an instant in time to millisecond precision or
    NaN representing no specific instant.
By flooring the value we match the behavior in the Temporal proposal's
Temporal.ZonedDateTime.prototype.epochMilliseconds getter:
    4. Let ms be RoundTowardsZero(ℝ(ns) / 10^6).
With that being defined as:
    13.30 RoundTowardsZero ( x )
    https://tc39.es/proposal-temporal/#sec-temporal-roundtowardszero
    1. Return the mathematical value that is the same sign as x and
    whose magnitude is floor(abs(x)).
This is makes the last of the currently 15 Temporal tests in test262
work, which compares Temporal.now.instant() with Date.now() :^)
		
	
			
		
			
				
	
	
		
			11 lines
		
	
	
	
		
			330 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			11 lines
		
	
	
	
		
			330 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
| test("basic functionality", () => {
 | |
|     var last = 0;
 | |
|     for (var i = 0; i < 100; ++i) {
 | |
|         var now = Date.now();
 | |
|         expect(now).not.toBeNaN();
 | |
|         expect(Math.floor(now)).toBe(now);
 | |
|         expect(now).toBeGreaterThan(1580000000000);
 | |
|         expect(now).toBeGreaterThanOrEqual(last);
 | |
|         last = now;
 | |
|     }
 | |
| });
 |