Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Normative: Fix inconsistent property names/order returned by getISOFields() #1510

Merged
merged 2 commits into from
May 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions polyfill/test/PlainDate/prototype/getISOFields/field-names.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// 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.plaindate.prototype.getisofields
description: Correct field names on the object returned from getISOFields
---*/

const date = new Temporal.PlainDate(2000, 5, 2);

const result = date.getISOFields();
assert.sameValue(result.isoYear, 2000, "isoYear result");
assert.sameValue(result.isoMonth, 5, "isoMonth result");
assert.sameValue(result.isoDay, 2, "isoDay result");
assert.sameValue(result.calendar.id, "iso8601", "calendar result");
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// 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.plaindate.prototype.getisofields
description: Properties added in correct order to object returned from getISOFields
includes: [compareArray.js]
---*/

const expected = [
"calendar",
"isoDay",
"isoMonth",
"isoYear",
];

const date = new Temporal.PlainDate(2000, 5, 2);
const result = date.getISOFields();

assert.compareArray(Object.keys(result), expected);
21 changes: 21 additions & 0 deletions polyfill/test/PlainDateTime/prototype/getISOFields/field-names.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// 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.plaindatetime.prototype.getisofields
description: Correct field names on the object returned from getISOFields
---*/

const datetime = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321);

const result = datetime.getISOFields();
assert.sameValue(result.isoYear, 2000, "isoYear result");
assert.sameValue(result.isoMonth, 5, "isoMonth result");
assert.sameValue(result.isoDay, 2, "isoDay result");
assert.sameValue(result.isoHour, 12, "isoHour result");
assert.sameValue(result.isoMinute, 34, "isoMinute result");
assert.sameValue(result.isoSecond, 56, "isoSecond result");
assert.sameValue(result.isoMillisecond, 987, "isoMillisecond result");
assert.sameValue(result.isoMicrosecond, 654, "isoMicrosecond result");
assert.sameValue(result.isoNanosecond, 321, "isoNanosecond result");
assert.sameValue(result.calendar.id, "iso8601", "calendar result");
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// 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.plaindatetime.prototype.getisofields
description: Properties added in correct order to object returned from getISOFields
includes: [compareArray.js]
---*/

const expected = [
"calendar",
"isoDay",
"isoHour",
"isoMicrosecond",
"isoMillisecond",
"isoMinute",
"isoMonth",
"isoNanosecond",
"isoSecond",
"isoYear",
];

const datetime = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321);
const result = datetime.getISOFields();

assert.compareArray(Object.keys(result), expected);
15 changes: 15 additions & 0 deletions polyfill/test/PlainMonthDay/prototype/getISOFields/field-names.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// 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.plainmonthday.prototype.getisofields
description: Correct field names on the object returned from getISOFields
---*/

const md = new Temporal.PlainMonthDay(5, 2);

const result = md.getISOFields();
assert.sameValue(result.isoYear, 1972, "isoYear result");
assert.sameValue(result.isoMonth, 5, "isoMonth result");
assert.sameValue(result.isoDay, 2, "isoDay result");
assert.sameValue(result.calendar.id, "iso8601", "calendar result");
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// 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.plainmonthday.prototype.getisofields
description: Properties added in correct order to object returned from getISOFields
includes: [compareArray.js]
---*/

const expected = [
"calendar",
"isoDay",
"isoMonth",
"isoYear",
];

const md = new Temporal.PlainMonthDay(5, 2);
const result = md.getISOFields();

assert.compareArray(Object.keys(result), expected);
18 changes: 18 additions & 0 deletions polyfill/test/PlainTime/prototype/getISOFields/field-names.js
Original file line number Diff line number Diff line change
@@ -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.plaintime.prototype.getisofields
description: Correct field names on the object returned from getISOFields
---*/

const time = new Temporal.PlainTime(12, 34, 56, 987, 654, 321);

const result = time.getISOFields();
assert.sameValue(result.isoHour, 12, "isoHour result");
assert.sameValue(result.isoMinute, 34, "isoMinute result");
assert.sameValue(result.isoSecond, 56, "isoSecond result");
assert.sameValue(result.isoMillisecond, 987, "isoMillisecond result");
assert.sameValue(result.isoMicrosecond, 654, "isoMicrosecond result");
assert.sameValue(result.isoNanosecond, 321, "isoNanosecond result");
assert.sameValue(result.calendar.id, "iso8601", "calendar result");
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// 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.plaintime.prototype.getisofields
description: Properties added in correct order to object returned from getISOFields
includes: [compareArray.js]
---*/

const expected = [
"calendar",
"isoHour",
"isoMicrosecond",
"isoMillisecond",
"isoMinute",
"isoNanosecond",
"isoSecond",
];

const time = new Temporal.PlainTime(12, 34, 56, 987, 654, 321);
const result = time.getISOFields();

assert.compareArray(Object.keys(result), expected);
15 changes: 15 additions & 0 deletions polyfill/test/PlainYearMonth/prototype/getISOFields/field-names.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// 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.plainyearmonth.prototype.getisofields
description: Correct field names on the object returned from getISOFields
---*/

const ym = new Temporal.PlainYearMonth(2000, 5);

const result = ym.getISOFields();
assert.sameValue(result.isoYear, 2000, "isoYear result");
assert.sameValue(result.isoMonth, 5, "isoMonth result");
assert.sameValue(result.isoDay, 1, "isoDay result");
assert.sameValue(result.calendar.id, "iso8601", "calendar result");
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// 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.plainyearmonth.prototype.getisofields
description: Properties added in correct order to object returned from getISOFields
includes: [compareArray.js]
---*/

const expected = [
"calendar",
"isoDay",
"isoMonth",
"isoYear",
];

const ym = new Temporal.PlainYearMonth(2000, 5);
const result = ym.getISOFields();

assert.compareArray(Object.keys(result), expected);
23 changes: 23 additions & 0 deletions polyfill/test/ZonedDateTime/prototype/getISOFields/field-names.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// 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: Correct field names on the object returned from getISOFields
---*/

const datetime = new Temporal.ZonedDateTime(1_000_086_400_987_654_321n, "UTC");

const result = datetime.getISOFields();
assert.sameValue(result.isoYear, 2001, "isoYear result");
assert.sameValue(result.isoMonth, 9, "isoMonth result");
assert.sameValue(result.isoDay, 10, "isoDay result");
assert.sameValue(result.isoHour, 1, "isoHour result");
assert.sameValue(result.isoMinute, 46, "isoMinute result");
assert.sameValue(result.isoSecond, 40, "isoSecond result");
assert.sameValue(result.isoMillisecond, 987, "isoMillisecond result");
assert.sameValue(result.isoMicrosecond, 654, "isoMicrosecond result");
assert.sameValue(result.isoNanosecond, 321, "isoNanosecond result");
assert.sameValue(result.offset, "+00:00", "offset result");
assert.sameValue(result.calendar.id, "iso8601", "calendar result");
assert.sameValue(result.timeZone.id, "UTC", "timeZone result");
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// 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: Properties added in correct order to object returned from getISOFields
includes: [compareArray.js]
---*/

const expected = [
"calendar",
"isoDay",
"isoHour",
"isoMicrosecond",
"isoMillisecond",
"isoMinute",
"isoMonth",
"isoNanosecond",
"isoSecond",
"isoYear",
"offset",
"timeZone",
];

const datetime = new Temporal.ZonedDateTime(1_000_086_400_987_654_321n, "UTC");
const result = datetime.getISOFields();

assert.compareArray(Object.keys(result), expected);
2 changes: 1 addition & 1 deletion spec/plaindatetime.html
Original file line number Diff line number Diff line change
Expand Up @@ -712,10 +712,10 @@ <h1>Temporal.PlainDateTime.prototype.getISOFields ( )</h1>
1. Perform ! CreateDataPropertyOrThrow(_fields_, *"calendar"*, _dateTime_.[[Calendar]]).
1. Perform ! CreateDataPropertyOrThrow(_fields_, *"isoDay"*, 𝔽(_dateTime_.[[ISODay]])).
1. Perform ! CreateDataPropertyOrThrow(_fields_, *"isoHour"*, 𝔽(_dateTime_.[[ISOHour]])).
1. Perform ! CreateDataPropertyOrThrow(_fields_, *"isoMonth"*, 𝔽(_dateTime_.[[ISOMonth]])).
1. Perform ! CreateDataPropertyOrThrow(_fields_, *"isoMicrosecond"*, 𝔽(_dateTime_.[[ISOMicrosecond]])).
1. Perform ! CreateDataPropertyOrThrow(_fields_, *"isoMillisecond"*, 𝔽(_dateTime_.[[ISOMillisecond]])).
1. Perform ! CreateDataPropertyOrThrow(_fields_, *"isoMinute"*, 𝔽(_dateTime_.[[ISOMinute]])).
1. Perform ! CreateDataPropertyOrThrow(_fields_, *"isoMonth"*, 𝔽(_dateTime_.[[ISOMonth]])).
1. Perform ! CreateDataPropertyOrThrow(_fields_, *"isoNanosecond"*, 𝔽(_dateTime_.[[ISONanosecond]])).
1. Perform ! CreateDataPropertyOrThrow(_fields_, *"isoSecond"*, 𝔽(_dateTime_.[[Second]])).
1. Perform ! CreateDataPropertyOrThrow(_fields_, *"isoYear"*, 𝔽(_dateTime_.[[ISOYear]])).
Expand Down
12 changes: 6 additions & 6 deletions spec/zoneddatetime.html
Original file line number Diff line number Diff line change
Expand Up @@ -997,16 +997,16 @@ <h1>Temporal.ZonedDateTime.prototype.getISOFields ( )</h1>
1. Let _dateTime_ be ? BuiltinTimeZoneGetPlainDateTimeFor(_timeZone_, _instant_, _calendar_).
1. Let _offset_ be ? BuiltinTimeZoneGetOffsetStringFor(_timeZone_, _instant_).
1. Perform ! CreateDataPropertyOrThrow(_fields_, *"calendar"*, _calendar_).
1. Perform ! CreateDataPropertyOrThrow(_fields_, *"hour"*, _dateTime_.[[ISOHour]]).
1. Perform ! CreateDataPropertyOrThrow(_fields_, *"isoDay"*, _dateTime_.[[ISODay]]).
1. Perform ! CreateDataPropertyOrThrow(_fields_, *"isoHour"*, _dateTime_.[[ISOHour]]).
1. Perform ! CreateDataPropertyOrThrow(_fields_, *"isoMicrosecond"*, _dateTime_.[[ISOMicrosecond]]).
1. Perform ! CreateDataPropertyOrThrow(_fields_, *"isoMillisecond"*, _dateTime_.[[ISOMillisecond]]).
1. Perform ! CreateDataPropertyOrThrow(_fields_, *"isoMinute"*, _dateTime_.[[ISOMinute]]).
1. Perform ! CreateDataPropertyOrThrow(_fields_, *"isoMonth"*, _dateTime_.[[ISOMonth]]).
1. Perform ! CreateDataPropertyOrThrow(_fields_, *"isoNanosecond"*, _dateTime_.[[ISONanosecond]]).
1. Perform ! CreateDataPropertyOrThrow(_fields_, *"isoSecond"*, _dateTime_.[[ISOSecond]]).
1. Perform ! CreateDataPropertyOrThrow(_fields_, *"isoYear"*, _dateTime_.[[ISOYear]]).
1. Perform ! CreateDataPropertyOrThrow(_fields_, *"microsecond"*, _dateTime_.[[ISOMicrosecond]]).
1. Perform ! CreateDataPropertyOrThrow(_fields_, *"millisecond"*, _dateTime_.[[ISOMillisecond]]).
1. Perform ! CreateDataPropertyOrThrow(_fields_, *"minute"*, _dateTime_.[[ISOMinute]]).
1. Perform ! CreateDataPropertyOrThrow(_fields_, *"nanosecond"*, _dateTime_.[[ISONanosecond]]).
1. Perform ! CreateDataPropertyOrThrow(_fields_, *"offset"*, _offset_).
1. Perform ! CreateDataPropertyOrThrow(_fields_, *"second"*, _dateTime_.[[ISOSecond]]).
1. Perform ! CreateDataPropertyOrThrow(_fields_, *"timeZone"*, _timeZone_).
1. Return _fields_.
</emu-alg>
Expand Down