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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
|
// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally
// Copyright (C) 2021 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-temporal.calendar.prototype.datefromfields
description: Temporal.Calendar.prototype.dateFromFields with year/month/day and need constrain
info: |
1. Let calendar be the this value.
2. Perform ? RequireInternalSlot(calendar, [[InitializedTemporalCalendar]]).
3. Assert: calendar.[[Identifier]] is "iso8601".
4. If Type(fields) is not Object, throw a TypeError exception.
5. Set options to ? GetOptionsObject(options).
6. Let result be ? ISODateFromFields(fields, options).
7. Return ? CreateTemporalDate(result.[[Year]], result.[[Month]], result.[[Day]], calendar).
features: [Temporal]
includes: [temporalHelpers.js]
---*/
let cal = new Temporal.Calendar("iso8601")
TemporalHelpers.assertPlainDate(
cal.dateFromFields({year: 2021, month: 1, day: 133}),
2021, 1, "M01", 31,
"year/month/day with day need to be constrained in Jan");
TemporalHelpers.assertPlainDate(
cal.dateFromFields({year: 2021, month: 2, day: 133}),
2021, 2, "M02", 28,
"year/month/day with day need to be constrained in Feb");
TemporalHelpers.assertPlainDate(
cal.dateFromFields({year: 2021, month: 3, day: 133}),
2021, 3, "M03", 31,
"year/month/day with day need to be constrained in March");
TemporalHelpers.assertPlainDate(
cal.dateFromFields({year: 2021, month: 4, day: 133}),
2021, 4, "M04", 30,
"year/month/day with day need to be constrained in April");
TemporalHelpers.assertPlainDate(
cal.dateFromFields({year: 2021, month: 5, day: 133}),
2021, 5, "M05", 31,
"year/month/day with day need to be constrained in May");
TemporalHelpers.assertPlainDate(
cal.dateFromFields({year: 2021, month: 6, day: 133}),
2021, 6, "M06", 30,
"year/month/day with day need to be constrained in Jun");
TemporalHelpers.assertPlainDate(
cal.dateFromFields({year: 2021, month: 7, day: 133}),
2021, 7, "M07", 31,
"year/month/day with day need to be constrained in July");
TemporalHelpers.assertPlainDate(
cal.dateFromFields({year: 2021, month: 8, day: 133}),
2021, 8, "M08", 31,
"year/month/day with day need to be constrained in Aug");
TemporalHelpers.assertPlainDate(
cal.dateFromFields({year: 2021, month: 9, day: 133}),
2021, 9, "M09", 30,
"year/month/day with day need to be constrained in Sept.");
TemporalHelpers.assertPlainDate(
cal.dateFromFields({year: 2021, month: 10, day: 133}),
2021, 10, "M10", 31,
"year/month/day with day need to be constrained in Oct.");
TemporalHelpers.assertPlainDate(
cal.dateFromFields({year: 2021, month: 11, day: 133}),
2021, 11, "M11", 30,
"year/month/day with day need to be constrained in Nov.");
TemporalHelpers.assertPlainDate(
cal.dateFromFields({year: 2021, month: 12, day: 133}),
2021, 12, "M12", 31,
"year/month/day with day need to be constrained in Dec.");
TemporalHelpers.assertPlainDate(
cal.dateFromFields({year: 2021, month: 13, day: 500}),
2021, 12, "M12", 31,
"year/month/day with month and day need to be constrained");
TemporalHelpers.assertPlainDate(
cal.dateFromFields({year: 2021, month: 999999, day: 500}),
2021, 12, "M12", 31,
"year/month/day with month and day need to be constrained");
reportCompare(0, 0);
|