mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 22:12:44 +00:00 
			
		
		
		
	 392f5bfebd
			
		
	
	
		392f5bfebd
		
	
	
	
	
		
			
			Two issues: - The intended range was 9 characters starting from index 1. Since the second argument to String::substring() is the length, 10 is potentially reading further than the string's length (when only providing one fraction digit), causing an assertion failure crash. - The spec's intention to skip the decimal separator by starting at index 1 is incorrect, no decimal separator is present in the result of parsing TimeZoneUTCOffsetFractionalPart. I filed a spec fix for this, see: https://github.com/tc39/proposal-temporal/pull/1999
		
			
				
	
	
		
			44 lines
		
	
	
	
		
			1.8 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			44 lines
		
	
	
	
		
			1.8 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
| describe("normal behavior", () => {
 | |
|     test("length is 1", () => {
 | |
|         expect(Temporal.TimeZone.from).toHaveLength(1);
 | |
|     });
 | |
| 
 | |
|     test("basic functionality", () => {
 | |
|         // From object
 | |
|         const timeZone = new Temporal.TimeZone("UTC");
 | |
|         const timeZoneLike = {};
 | |
|         const zonedDateTimeLike = { timeZone: {} };
 | |
|         expect(Temporal.TimeZone.from(timeZone)).toBe(timeZone);
 | |
|         expect(Temporal.TimeZone.from(timeZoneLike)).toBe(timeZoneLike);
 | |
|         expect(Temporal.TimeZone.from(zonedDateTimeLike)).toBe(zonedDateTimeLike.timeZone);
 | |
| 
 | |
|         // From string
 | |
|         const values = [
 | |
|             ["UTC", "UTC"],
 | |
|             ["GMT", "UTC"],
 | |
|             ["Etc/UTC", "UTC"],
 | |
|             ["Etc/GMT", "UTC"],
 | |
|             // FIXME: https://github.com/tc39/proposal-temporal/issues/1993
 | |
|             // ["Etc/GMT+12", "Etc/GMT+12"],
 | |
|             // ["Etc/GMT-12", "Etc/GMT-12"],
 | |
|             ["Europe/London", "Europe/London"],
 | |
|             ["Europe/Isle_of_Man", "Europe/London"],
 | |
|             ["1970-01-01+01", "+01:00"],
 | |
|             ["1970-01-01+01[-12:34]", "+01:00"],
 | |
|             ["1970-01-01T00:00:00+01", "+01:00"],
 | |
|             ["1970-01-01T00:00:00.000000000+01", "+01:00"],
 | |
|             ["1970-01-01T00:00:00.000000000+01:00:00", "+01:00"],
 | |
|             ["1970-01-01+12:34", "+12:34"],
 | |
|             ["1970-01-01+12:34:56", "+12:34:56"],
 | |
|             ["1970-01-01+12:34:56.789", "+12:34:56.789"],
 | |
|             ["1970-01-01+12:34:56.789[-01:00]", "+12:34:56.789"],
 | |
|             ["1970-01-01-12:34", "-12:34"],
 | |
|             ["1970-01-01-12:34:56", "-12:34:56"],
 | |
|             ["1970-01-01-12:34:56.789", "-12:34:56.789"],
 | |
|             ["1970-01-01-12:34:56.789[+01:00]", "-12:34:56.789"],
 | |
|         ];
 | |
|         for (const [arg, expected] of values) {
 | |
|             expect(Temporal.TimeZone.from(arg).id).toBe(expected);
 | |
|         }
 | |
|     });
 | |
| });
 |