| 1 |
// |reftest| shell-option(--enable-temporal) skip-if(!this.hasOwnProperty('Temporal')||!xulRuntime.shell) -- Temporal is not enabled unconditionally, requires shell-options |
| 2 |
// Copyright (C) 2024 Igalia, S.L. All rights reserved. |
| 3 |
// This code is governed by the BSD license found in the LICENSE file. |
| 4 |
|
| 5 |
/*--- |
| 6 |
esid: sec-temporal.zoneddatetime |
| 7 |
description: > |
| 8 |
Test construction and properties of an instance with non-UTC time zone and |
| 9 |
non-ISO8601 calendar |
| 10 |
includes: [temporalHelpers.js] |
| 11 |
features: [Temporal, BigInt] |
| 12 |
---*/ |
| 13 |
|
| 14 |
var epochMillis = Date.UTC(1976, 10, 18, 15, 23, 30, 123); |
| 15 |
var epochNanos = BigInt(epochMillis) * 1000000n + 456789n; |
| 16 |
|
| 17 |
const instance = new Temporal.ZonedDateTime(epochNanos, "Europe/Vienna", "gregory"); |
| 18 |
assert(instance instanceof Temporal.ZonedDateTime, "instanceof is correct"); |
| 19 |
assert.sameValue(typeof instance, "object", "typeof is correct"); |
| 20 |
|
| 21 |
assert.sameValue( |
| 22 |
TemporalHelpers.canonicalizeCalendarEra(instance.calendarId, instance.era), |
| 23 |
TemporalHelpers.canonicalizeCalendarEra(instance.calendarId, "ce"), |
| 24 |
"era" |
| 25 |
); |
| 26 |
assert.sameValue(instance.eraYear, 1976, "eraYear"); |
| 27 |
assert.sameValue(instance.year, 1976, "year"); |
| 28 |
assert.sameValue(instance.month, 11, "month"); |
| 29 |
assert.sameValue(instance.monthCode, "M11", "monthCode"); |
| 30 |
assert.sameValue(instance.day, 18, "day"); |
| 31 |
assert.sameValue(instance.hour, 16, "hour"); |
| 32 |
assert.sameValue(instance.minute, 23, "minute"); |
| 33 |
assert.sameValue(instance.second, 30, "second"); |
| 34 |
assert.sameValue(instance.millisecond, 123, "millisecond"); |
| 35 |
assert.sameValue(instance.microsecond, 456, "microsecond"); |
| 36 |
assert.sameValue(instance.nanosecond, 789, "nanosecond"); |
| 37 |
|
| 38 |
assert.sameValue(instance.epochMilliseconds, 217178610123, "epochMilliseconds"); |
| 39 |
assert.sameValue(instance.epochNanoseconds, 217178610123456789n, "epochNanoseconds"); |
| 40 |
|
| 41 |
assert.sameValue(instance.dayOfWeek, 4, "dayOfWeek"); |
| 42 |
assert.sameValue(instance.dayOfYear, 323, "dayOfYear"); |
| 43 |
assert.sameValue(instance.weekOfYear, undefined, "weekOfYear"); |
| 44 |
assert.sameValue(instance.yearOfWeek, undefined, "yearOfWeek"); |
| 45 |
assert.sameValue(instance.daysInWeek, 7, "daysInWeek"); |
| 46 |
assert.sameValue(instance.daysInMonth, 30, "daysInMonth"); |
| 47 |
assert.sameValue(instance.daysInYear, 366, "daysInYear"); |
| 48 |
assert.sameValue(instance.monthsInYear, 12, "monthsInYear"); |
| 49 |
assert.sameValue(instance.inLeapYear, true, "inLeapYear"); |
| 50 |
|
| 51 |
assert.sameValue(instance.offset, "+01:00", "offset"); |
| 52 |
assert.sameValue(instance.offsetNanoseconds, 3600e9, "offsetNanoseconds"); |
| 53 |
|
| 54 |
reportCompare(0, 0); |