mirror of https://github.com/tc39/test262.git
Add tests for Temporal.Calendar.prototype.dayOf*
This commit is contained in:
parent
97967a37b3
commit
52bb16f9a5
|
@ -0,0 +1,34 @@
|
|||
// 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.dayofweek
|
||||
description: Temporal.Calendar.prototype.dayOfWeek will take Temporal.PlainDateTime objects
|
||||
and return the day of week.
|
||||
|
||||
info: |
|
||||
1. Let calendar be the this value.
|
||||
2. Perform ? RequireInternalSlot(calendar, [[InitializedTemporalCalendar]]).
|
||||
3. Assert: calendar.[[Identifier]] is "iso8601".
|
||||
4. Let temporalDate be ? ToTemporalDate(temporalDateLike).
|
||||
5. Return 𝔽(! ToISODayOfWeek(temporalDate.[[ISOYear]], temporalDate.[[ISOMonth]], temporalDate.[[ISODay]])).
|
||||
features: [Temporal]
|
||||
---*/
|
||||
let cal = new Temporal.Calendar("iso8601");
|
||||
|
||||
assert.sameValue(4, cal.dayOfWeek(new Temporal.PlainDateTime(1997, 1, 23, 5, 30, 13)));
|
||||
// leap year
|
||||
assert.sameValue(5, cal.dayOfWeek(new Temporal.PlainDateTime(1996, 2, 23, 5, 30, 13)));
|
||||
assert.sameValue(3, cal.dayOfWeek(new Temporal.PlainDateTime(2000, 2, 23, 5, 30, 13)));
|
||||
// non leap year
|
||||
assert.sameValue(7, cal.dayOfWeek(new Temporal.PlainDateTime(1997, 2, 23, 5, 30, 13)));
|
||||
assert.sameValue(7, cal.dayOfWeek(new Temporal.PlainDateTime(1997, 3, 23, 5, 30, 13)));
|
||||
assert.sameValue(3, cal.dayOfWeek(new Temporal.PlainDateTime(1997, 4, 23, 5, 30, 13)));
|
||||
assert.sameValue(5, cal.dayOfWeek(new Temporal.PlainDateTime(1997, 5, 23, 5, 30, 13)));
|
||||
assert.sameValue(1, cal.dayOfWeek(new Temporal.PlainDateTime(1997, 6, 23, 5, 30, 13)));
|
||||
assert.sameValue(3, cal.dayOfWeek(new Temporal.PlainDateTime(1997, 7, 23, 5, 30, 13)));
|
||||
assert.sameValue(6, cal.dayOfWeek(new Temporal.PlainDateTime(1997, 8, 23, 5, 30, 13)));
|
||||
assert.sameValue(2, cal.dayOfWeek(new Temporal.PlainDateTime(1997, 9, 23, 5, 30, 13)));
|
||||
assert.sameValue(4, cal.dayOfWeek(new Temporal.PlainDateTime(1997, 10, 23, 5, 30, 13)));
|
||||
assert.sameValue(7, cal.dayOfWeek(new Temporal.PlainDateTime(1997, 11, 23, 5, 30, 13)));
|
||||
assert.sameValue(2, cal.dayOfWeek(new Temporal.PlainDateTime(1997, 12, 23, 5, 30, 13)));
|
|
@ -0,0 +1,37 @@
|
|||
// 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.dayofweek
|
||||
description: Temporal.Calendar.prototype.dayOfWeek will take Temporal.PlainDate objects
|
||||
and return the day of week.
|
||||
|
||||
info: |
|
||||
1. Let calendar be the this value.
|
||||
2. Perform ? RequireInternalSlot(calendar, [[InitializedTemporalCalendar]]).
|
||||
3. Assert: calendar.[[Identifier]] is "iso8601".
|
||||
4. Let temporalDate be ? ToTemporalDate(temporalDateLike).
|
||||
5. Return 𝔽(! ToISODayOfWeek(temporalDate.[[ISOYear]], temporalDate.[[ISOMonth]], temporalDate.[[ISODay]])).
|
||||
features: [Temporal]
|
||||
---*/
|
||||
let cal = new Temporal.Calendar("iso8601");
|
||||
|
||||
assert.sameValue(4, cal.dayOfWeek(new Temporal.PlainDate(1970, 1, 1)));
|
||||
assert.sameValue(6, cal.dayOfWeek(new Temporal.PlainDate(2000, 1, 1)));
|
||||
|
||||
assert.sameValue(5, cal.dayOfWeek(new Temporal.PlainDate(2021, 1, 15)));
|
||||
// leap year
|
||||
assert.sameValue(6, cal.dayOfWeek(new Temporal.PlainDate(2020, 2, 15)));
|
||||
assert.sameValue(2, cal.dayOfWeek(new Temporal.PlainDate(2000, 2, 15)));
|
||||
// non-leap year
|
||||
assert.sameValue(1, cal.dayOfWeek(new Temporal.PlainDate(2021, 2, 15)));
|
||||
assert.sameValue(1, cal.dayOfWeek(new Temporal.PlainDate(2021, 3, 15)));
|
||||
assert.sameValue(4, cal.dayOfWeek(new Temporal.PlainDate(2021, 4, 15)));
|
||||
assert.sameValue(6, cal.dayOfWeek(new Temporal.PlainDate(2021, 5, 15)));
|
||||
assert.sameValue(2, cal.dayOfWeek(new Temporal.PlainDate(2021, 6, 15)));
|
||||
assert.sameValue(4, cal.dayOfWeek(new Temporal.PlainDate(2021, 7, 15)));
|
||||
assert.sameValue(7, cal.dayOfWeek(new Temporal.PlainDate(2021, 8, 15)));
|
||||
assert.sameValue(3, cal.dayOfWeek(new Temporal.PlainDate(2021, 9, 15)));
|
||||
assert.sameValue(5, cal.dayOfWeek(new Temporal.PlainDate(2021, 10, 15)));
|
||||
assert.sameValue(1, cal.dayOfWeek(new Temporal.PlainDate(2021, 11, 15)));
|
||||
assert.sameValue(3, cal.dayOfWeek(new Temporal.PlainDate(2021, 12, 15)));
|
|
@ -0,0 +1,33 @@
|
|||
// 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.dayofweek
|
||||
description: Temporal.Calendar.prototype.dayOfWeek will take ISO8601 string
|
||||
and return the day of week.
|
||||
|
||||
info: |
|
||||
1. Let calendar be the this value.
|
||||
2. Perform ? RequireInternalSlot(calendar, [[InitializedTemporalCalendar]]).
|
||||
3. Assert: calendar.[[Identifier]] is "iso8601".
|
||||
4. Let temporalDate be ? ToTemporalDate(temporalDateLike).
|
||||
5. Return 𝔽(! ToISODayOfWeek(temporalDate.[[ISOYear]], temporalDate.[[ISOMonth]], temporalDate.[[ISODay]])).
|
||||
features: [Temporal]
|
||||
---*/
|
||||
let cal = new Temporal.Calendar("iso8601");
|
||||
|
||||
assert.sameValue(5, cal.dayOfWeek("2019-01-18"));
|
||||
// leap year
|
||||
assert.sameValue(2, cal.dayOfWeek("2020-02-18"));
|
||||
// non leap
|
||||
assert.sameValue(1, cal.dayOfWeek("2019-02-18"));
|
||||
assert.sameValue(1, cal.dayOfWeek("2019-03-18"));
|
||||
assert.sameValue(4, cal.dayOfWeek("2019-04-18"));
|
||||
assert.sameValue(6, cal.dayOfWeek("2019-05-18"));
|
||||
assert.sameValue(2, cal.dayOfWeek("2019-06-18"));
|
||||
assert.sameValue(4, cal.dayOfWeek("2019-07-18"));
|
||||
assert.sameValue(7, cal.dayOfWeek("2019-08-18"));
|
||||
assert.sameValue(3, cal.dayOfWeek("2019-09-18"));
|
||||
assert.sameValue(5, cal.dayOfWeek("2019-10-18"));
|
||||
assert.sameValue(1, cal.dayOfWeek("2019-11-18"));
|
||||
assert.sameValue(3, cal.dayOfWeek("2019-12-18"));
|
|
@ -0,0 +1,24 @@
|
|||
// 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.dayofyear
|
||||
description: Temporal.Calendar.prototype.dayOfYear will take PlainDateTime object and
|
||||
return the day of year.
|
||||
and return Array of the same content.
|
||||
info: |
|
||||
1. Let calendar be the this value.
|
||||
2. Perform ? RequireInternalSlot(calendar, [[InitializedTemporalCalendar]]).
|
||||
3. Assert: calendar.[[Identifier]] is "iso8601".
|
||||
4. Let temporalDate be ? ToTemporalDate(temporalDateLike).
|
||||
5. Return 𝔽(! ToISODayOfYear(temporalDate.[[ISOYear]], temporalDate.[[ISOMonth]], temporalDate.[[ISODay]])).
|
||||
features: [Temporal]
|
||||
---*/
|
||||
let cal = new Temporal.Calendar("iso8601");
|
||||
|
||||
assert.sameValue(23, cal.dayOfYear(new Temporal.PlainDateTime(1997, 1, 23, 5, 30, 13)));
|
||||
assert.sameValue(54, cal.dayOfYear(new Temporal.PlainDateTime(1997, 2, 23, 5, 30, 13)));
|
||||
assert.sameValue(83, cal.dayOfYear(new Temporal.PlainDateTime(1996, 3, 23, 5, 30, 13)));
|
||||
assert.sameValue(82, cal.dayOfYear(new Temporal.PlainDateTime(1997, 3, 23, 5, 30, 13)));
|
||||
assert.sameValue(365, cal.dayOfYear(new Temporal.PlainDateTime(1997, 12, 31, 5, 30, 13)));
|
||||
assert.sameValue(366, cal.dayOfYear(new Temporal.PlainDateTime(1996, 12, 31, 5, 30, 13)));
|
|
@ -0,0 +1,29 @@
|
|||
// 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.dayofyear
|
||||
description: Temporal.Calendar.prototype.dayOfYear will take PlainDate object and
|
||||
return the day of year.
|
||||
and return Array of the same content.
|
||||
info: |
|
||||
1. Let calendar be the this value.
|
||||
2. Perform ? RequireInternalSlot(calendar, [[InitializedTemporalCalendar]]).
|
||||
3. Assert: calendar.[[Identifier]] is "iso8601".
|
||||
4. Let temporalDate be ? ToTemporalDate(temporalDateLike).
|
||||
5. Return 𝔽(! ToISODayOfYear(temporalDate.[[ISOYear]], temporalDate.[[ISOMonth]], temporalDate.[[ISODay]])).
|
||||
features: [Temporal]
|
||||
---*/
|
||||
let cal = new Temporal.Calendar("iso8601");
|
||||
|
||||
assert.sameValue(1, cal.dayOfYear(new Temporal.PlainDate(1970, 1, 1)));
|
||||
assert.sameValue(1, cal.dayOfYear(new Temporal.PlainDate(2000, 1, 1)));
|
||||
|
||||
assert.sameValue(15, cal.dayOfYear(new Temporal.PlainDate(2021, 1, 15)));
|
||||
assert.sameValue(46, cal.dayOfYear(new Temporal.PlainDate(2020, 2, 15)));
|
||||
assert.sameValue(46, cal.dayOfYear(new Temporal.PlainDate(2000, 2, 15)));
|
||||
assert.sameValue(75, cal.dayOfYear(new Temporal.PlainDate(2020, 3, 15)));
|
||||
assert.sameValue(75, cal.dayOfYear(new Temporal.PlainDate(2000, 3, 15)));
|
||||
assert.sameValue(74, cal.dayOfYear(new Temporal.PlainDate(2001, 3, 15)));
|
||||
assert.sameValue(366, cal.dayOfYear(new Temporal.PlainDate(2000, 12, 31)));
|
||||
assert.sameValue(365, cal.dayOfYear(new Temporal.PlainDate(2001, 12, 31)));
|
|
@ -0,0 +1,22 @@
|
|||
// 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.dayofyear
|
||||
description: Temporal.Calendar.prototype.dayOfYear will take ISO8601 string and
|
||||
return the day of year.
|
||||
and return Array of the same content.
|
||||
info: |
|
||||
1. Let calendar be the this value.
|
||||
2. Perform ? RequireInternalSlot(calendar, [[InitializedTemporalCalendar]]).
|
||||
3. Assert: calendar.[[Identifier]] is "iso8601".
|
||||
4. Let temporalDate be ? ToTemporalDate(temporalDateLike).
|
||||
5. Return 𝔽(! ToISODayOfYear(temporalDate.[[ISOYear]], temporalDate.[[ISOMonth]], temporalDate.[[ISODay]])).
|
||||
features: [Temporal]
|
||||
---*/
|
||||
let cal = new Temporal.Calendar("iso8601");
|
||||
|
||||
assert.sameValue(18, cal.dayOfYear("2019-01-18"));
|
||||
assert.sameValue(49, cal.dayOfYear("2020-02-18"));
|
||||
assert.sameValue(365, cal.dayOfYear("2019-12-31"));
|
||||
assert.sameValue(366, cal.dayOfYear("2000-12-31"));
|
Loading…
Reference in New Issue