mirror of
				https://github.com/tc39/test262.git
				synced 2025-11-04 05:33:50 +01:00 
			
		
		
		
	Test positive and negative offset time zones in FormatTimeZoneOffset
Tests for the normative change made to Temporal in https://github.com/tc39/proposal-temporal/pull/1833
This commit is contained in:
		
							parent
							
								
									615408bc60
								
							
						
					
					
						commit
						0dec11d949
					
				
							
								
								
									
										19
									
								
								test/built-ins/Temporal/Instant/prototype/toString/timezone-offset.js
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										19
									
								
								test/built-ins/Temporal/Instant/prototype/toString/timezone-offset.js
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@ -0,0 +1,19 @@
 | 
				
			|||||||
 | 
					// Copyright (C) 2021 Igalia, S.L. All rights reserved.
 | 
				
			||||||
 | 
					// This code is governed by the BSD license found in the LICENSE file.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/*---
 | 
				
			||||||
 | 
					esid: sec-temporal.instant.prototype.tostring
 | 
				
			||||||
 | 
					description: The time zone offset part of the string serialization
 | 
				
			||||||
 | 
					features: [BigInt, Temporal]
 | 
				
			||||||
 | 
					---*/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const instant = new Temporal.Instant(0n);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					function test(timeZoneIdentifier, expected, description) {
 | 
				
			||||||
 | 
					  const timeZone = new Temporal.TimeZone(timeZoneIdentifier);
 | 
				
			||||||
 | 
					  assert.sameValue(instant.toString({ timeZone }), expected, description);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					test("UTC", "1970-01-01T00:00:00+00:00", "offset of UTC is +00:00");
 | 
				
			||||||
 | 
					test("+01:00", "1970-01-01T01:00:00+01:00", "positive offset");
 | 
				
			||||||
 | 
					test("-05:00", "1969-12-31T19:00:00-05:00", "negative offset");
 | 
				
			||||||
							
								
								
									
										19
									
								
								test/built-ins/Temporal/TimeZone/prototype/getOffsetStringFor/basic.js
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										19
									
								
								test/built-ins/Temporal/TimeZone/prototype/getOffsetStringFor/basic.js
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@ -0,0 +1,19 @@
 | 
				
			|||||||
 | 
					// Copyright (C) 2021 Igalia, S.L. All rights reserved.
 | 
				
			||||||
 | 
					// This code is governed by the BSD license found in the LICENSE file.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/*---
 | 
				
			||||||
 | 
					esid: sec-temporal.timezone.prototype.getoffsetstringfor
 | 
				
			||||||
 | 
					description: Basic tests for Temporal.TimeZone.prototype.getOffsetStringFor
 | 
				
			||||||
 | 
					features: [BigInt, Temporal]
 | 
				
			||||||
 | 
					---*/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const instant = new Temporal.Instant(0n);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					function test(timeZoneIdentifier, expectedOffsetString, description) {
 | 
				
			||||||
 | 
					  const timeZone = new Temporal.TimeZone(timeZoneIdentifier);
 | 
				
			||||||
 | 
					  assert.sameValue(timeZone.getOffsetStringFor(instant), expectedOffsetString, description);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					test("UTC", "+00:00", "offset of UTC is +00:00");
 | 
				
			||||||
 | 
					test("+01:00", "+01:00", "positive offset");
 | 
				
			||||||
 | 
					test("-05:00", "-05:00", "negative offset");
 | 
				
			||||||
							
								
								
									
										19
									
								
								test/built-ins/Temporal/ZonedDateTime/prototype/getISOFields/offset.js
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										19
									
								
								test/built-ins/Temporal/ZonedDateTime/prototype/getISOFields/offset.js
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@ -0,0 +1,19 @@
 | 
				
			|||||||
 | 
					// Copyright (C) 2021 Igalia, S.L. All rights reserved.
 | 
				
			||||||
 | 
					// This code is governed by the BSD license found in the LICENSE file.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/*---
 | 
				
			||||||
 | 
					esid: sec-temporal.zoneddatetime.prototype.getisofields
 | 
				
			||||||
 | 
					description: The offset property of returned object
 | 
				
			||||||
 | 
					features: [BigInt, Temporal]
 | 
				
			||||||
 | 
					---*/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					function test(timeZoneIdentifier, expectedOffsetString, description) {
 | 
				
			||||||
 | 
					  const timeZone = new Temporal.TimeZone(timeZoneIdentifier);
 | 
				
			||||||
 | 
					  const datetime = new Temporal.ZonedDateTime(0n, timeZone);
 | 
				
			||||||
 | 
					  const fields = datetime.getISOFields();
 | 
				
			||||||
 | 
					  assert.sameValue(fields.offset, expectedOffsetString, description);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					test("UTC", "+00:00", "offset of UTC is +00:00");
 | 
				
			||||||
 | 
					test("+01:00", "+01:00", "positive offset");
 | 
				
			||||||
 | 
					test("-05:00", "-05:00", "negative offset");
 | 
				
			||||||
							
								
								
									
										18
									
								
								test/built-ins/Temporal/ZonedDateTime/prototype/offset/basic.js
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										18
									
								
								test/built-ins/Temporal/ZonedDateTime/prototype/offset/basic.js
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@ -0,0 +1,18 @@
 | 
				
			|||||||
 | 
					// Copyright (C) 2021 Igalia, S.L. All rights reserved.
 | 
				
			||||||
 | 
					// This code is governed by the BSD license found in the LICENSE file.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/*---
 | 
				
			||||||
 | 
					esid: sec-get-temporal.zoneddatetime.prototype.offset
 | 
				
			||||||
 | 
					description: Basic tests for Temporal.ZonedDateTime.prototype.offset
 | 
				
			||||||
 | 
					features: [BigInt, Temporal]
 | 
				
			||||||
 | 
					---*/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					function test(timeZoneIdentifier, expectedOffsetString, description) {
 | 
				
			||||||
 | 
					  const timeZone = new Temporal.TimeZone(timeZoneIdentifier);
 | 
				
			||||||
 | 
					  const datetime = new Temporal.ZonedDateTime(0n, timeZone);
 | 
				
			||||||
 | 
					  assert.sameValue(datetime.offset, expectedOffsetString, description);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					test("UTC", "+00:00", "offset of UTC is +00:00");
 | 
				
			||||||
 | 
					test("+01:00", "+01:00", "positive offset");
 | 
				
			||||||
 | 
					test("-05:00", "-05:00", "negative offset");
 | 
				
			||||||
							
								
								
									
										18
									
								
								test/built-ins/Temporal/ZonedDateTime/prototype/toJSON/offset.js
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										18
									
								
								test/built-ins/Temporal/ZonedDateTime/prototype/toJSON/offset.js
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@ -0,0 +1,18 @@
 | 
				
			|||||||
 | 
					// Copyright (C) 2021 Igalia, S.L. All rights reserved.
 | 
				
			||||||
 | 
					// This code is governed by the BSD license found in the LICENSE file.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/*---
 | 
				
			||||||
 | 
					esid: sec-temporal.zoneddatetime.prototype.tojson
 | 
				
			||||||
 | 
					description: The time zone offset part of the string serialization
 | 
				
			||||||
 | 
					features: [BigInt, Temporal]
 | 
				
			||||||
 | 
					---*/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					function test(timeZoneIdentifier, expected, description) {
 | 
				
			||||||
 | 
					  const timeZone = new Temporal.TimeZone(timeZoneIdentifier);
 | 
				
			||||||
 | 
					  const datetime = new Temporal.ZonedDateTime(0n, timeZone);
 | 
				
			||||||
 | 
					  assert.sameValue(datetime.toJSON(), expected, description);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					test("UTC", "1970-01-01T00:00:00+00:00[UTC]", "offset of UTC is +00:00");
 | 
				
			||||||
 | 
					test("+01:00", "1970-01-01T01:00:00+01:00[+01:00]", "positive offset");
 | 
				
			||||||
 | 
					test("-05:00", "1969-12-31T19:00:00-05:00[-05:00]", "negative offset");
 | 
				
			||||||
							
								
								
									
										18
									
								
								test/built-ins/Temporal/ZonedDateTime/prototype/toString/offset.js
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										18
									
								
								test/built-ins/Temporal/ZonedDateTime/prototype/toString/offset.js
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@ -0,0 +1,18 @@
 | 
				
			|||||||
 | 
					// Copyright (C) 2021 Igalia, S.L. All rights reserved.
 | 
				
			||||||
 | 
					// This code is governed by the BSD license found in the LICENSE file.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/*---
 | 
				
			||||||
 | 
					esid: sec-temporal.zoneddatetime.prototype.tostring
 | 
				
			||||||
 | 
					description: The time zone offset part of the string serialization
 | 
				
			||||||
 | 
					features: [BigInt, Temporal]
 | 
				
			||||||
 | 
					---*/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					function test(timeZoneIdentifier, expected, description) {
 | 
				
			||||||
 | 
					  const timeZone = new Temporal.TimeZone(timeZoneIdentifier);
 | 
				
			||||||
 | 
					  const datetime = new Temporal.ZonedDateTime(0n, timeZone);
 | 
				
			||||||
 | 
					  assert.sameValue(datetime.toString(), expected, description);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					test("UTC", "1970-01-01T00:00:00+00:00[UTC]", "offset of UTC is +00:00");
 | 
				
			||||||
 | 
					test("+01:00", "1970-01-01T01:00:00+01:00[+01:00]", "positive offset");
 | 
				
			||||||
 | 
					test("-05:00", "1969-12-31T19:00:00-05:00[-05:00]", "negative offset");
 | 
				
			||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user