1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally
// Copyright (C) 2018 Bloomberg LP. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-temporal-zoneddatetime-objects
description: Temporal.ZonedDateTime.prototype.toPlainMonthDay()
features: [Temporal]
---*/
var tz = new Temporal.TimeZone("-08:00");
// works
var zdt = Temporal.Instant.from("2019-10-29T09:46:38.271986102Z").toZonedDateTimeISO(tz);
assert.sameValue(`${ zdt.toPlainMonthDay() }`, "10-29");
// preserves the calendar
var fakeGregorian = {
id: 'gregory',
monthDayFromFields(fields) {
var md = Temporal.Calendar.from("iso8601").monthDayFromFields(fields);
var {isoYear, isoMonth, isoDay} = md.getISOFields();
return new Temporal.PlainMonthDay(isoMonth, isoDay, this, isoYear);
},
monthCode(date) { return date.withCalendar("iso8601").monthCode; },
day(date) { return date.withCalendar("iso8601").day; },
dateAdd() {},
dateFromFields() {},
dateUntil() {},
dayOfWeek() {},
dayOfYear() {},
daysInMonth() {},
daysInWeek() {},
daysInYear() {},
fields(fieldNames) { return fieldNames; },
inLeapYear() {},
mergeFields() {},
month() {},
monthsInYear() {},
weekOfYear() {},
year() {},
yearMonthFromFields() {},
yearOfWeek() {},
};
var zdt = Temporal.Instant.from("2019-10-29T09:46:38.271986102Z").toZonedDateTime({
timeZone: tz,
calendar: fakeGregorian
});
assert.sameValue(zdt.toPlainMonthDay().getCalendar(), fakeGregorian);
reportCompare(0, 0);
|