| 1 |
// |reftest| shell-option(--enable-temporal) skip-if(!this.hasOwnProperty('Temporal')||!xulRuntime.shell) -- Temporal is not enabled unconditionally, requires shell-options |
| 2 |
// Copyright (C) 2018 Bloomberg LP. 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: Construction and properties. |
| 8 |
features: [Temporal] |
| 9 |
---*/ |
| 10 |
|
| 11 |
const epochMillis = Date.UTC(1976, 10, 18, 15, 23, 30, 123); |
| 12 |
const epochNanos = BigInt(epochMillis) * BigInt(1000000) + BigInt(456789); |
| 13 |
|
| 14 |
// works |
| 15 |
var zdt = new Temporal.ZonedDateTime(epochNanos, "-08:00"); |
| 16 |
assert(zdt instanceof Temporal.ZonedDateTime); |
| 17 |
assert.sameValue(typeof zdt, "object"); |
| 18 |
assert.sameValue(zdt.toInstant().epochMilliseconds, Date.UTC(1976, 10, 18, 15, 23, 30, 123), "epochMilliseconds"); |
| 19 |
|
| 20 |
// Temporal.ZonedDateTime for (1976, 11, 18, 15, 23, 30, 123, 456, 789)" |
| 21 |
zdt = new Temporal.ZonedDateTime(epochNanos, "UTC"); |
| 22 |
// can be constructed |
| 23 |
assert(zdt instanceof Temporal.ZonedDateTime); |
| 24 |
assert.sameValue(typeof zdt, "object"); |
| 25 |
|
| 26 |
assert.sameValue(zdt.year, 1976) |
| 27 |
assert.sameValue(zdt.month, 11); |
| 28 |
assert.sameValue(zdt.monthCode, "M11"); |
| 29 |
assert.sameValue(zdt.day, 18); |
| 30 |
assert.sameValue(zdt.hour, 15); |
| 31 |
assert.sameValue(zdt.minute, 23); |
| 32 |
assert.sameValue(zdt.second, 30); |
| 33 |
assert.sameValue(zdt.millisecond, 123); |
| 34 |
assert.sameValue(zdt.microsecond, 456); |
| 35 |
assert.sameValue(zdt.nanosecond, 789); |
| 36 |
assert.sameValue(zdt.epochMilliseconds, 217178610123); |
| 37 |
assert.sameValue(zdt.epochNanoseconds, 217178610123456789n); |
| 38 |
assert.sameValue(zdt.dayOfWeek, 4); |
| 39 |
assert.sameValue(zdt.dayOfYear, 323); |
| 40 |
assert.sameValue(zdt.weekOfYear, 47); |
| 41 |
assert.sameValue(zdt.daysInWeek, 7); |
| 42 |
assert.sameValue(zdt.daysInMonth, 30); |
| 43 |
assert.sameValue(zdt.daysInYear, 366); |
| 44 |
assert.sameValue(zdt.monthsInYear, 12); |
| 45 |
assert.sameValue(zdt.inLeapYear, true); |
| 46 |
assert.sameValue(zdt.offset, "+00:00"); |
| 47 |
assert.sameValue(zdt.offsetNanoseconds, 0); |
| 48 |
assert.sameValue(`${ zdt }`, "1976-11-18T15:23:30.123456789+00:00[UTC]"); |
| 49 |
|
| 50 |
reportCompare(0, 0); |