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

Batch of fixes for editorial issues #2735

Merged
merged 10 commits into from
Jan 8, 2024
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ Provides standard objects and functions for working with dates and times.

This proposal is currently [Stage 3](https://github.com/tc39/proposals#stage-3) and was reviewed for Stage 3 by Richard Gibson, Bradley Farias, and Daniel Ehrenberg.

**NOTE: Although this proposal's API is not expected to change, implementers of this proposal MUST NOT ship unflagged Temporal implementations until IETF standardizes timezone/calendar string serialization formats. See [#1450](https://github.com/tc39/proposal-temporal/issues/1450) for updates.**

This proposal is now in the hands of ECMAScript engine implementers, so the bar for making API changes is extremely high.
Nonetheless, changes may occur as the result of feedback from implementation in JS engines.
Editorial changes to the spec and bug fixes to the spec, tests, and docs are also ongoing, as is customary for Stage 3 proposals.
Expand Down
12 changes: 0 additions & 12 deletions docs/cookbook-nyse.md

This file was deleted.

6 changes: 0 additions & 6 deletions docs/cookbook.md
Original file line number Diff line number Diff line change
Expand Up @@ -570,9 +570,3 @@ Since they are generally larger than these cookbook recipes, they're on their ow
Extend `Temporal` to support arbitrarily-large years (e.g., **+635427810-02-02**) for astronomical purposes.

→ [Extra-expanded years](cookbook-expandedyears.md)

### New York Stock Exchange time zone

An example of using `Temporal.TimeZone` for other purposes than a standard time zone.

→ [NYSE time zone](cookbook-nyse.md)
228 changes: 0 additions & 228 deletions docs/cookbook/stockExchangeTimeZone.mjs

This file was deleted.

3 changes: 3 additions & 0 deletions docs/timezone.md
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,9 @@ tz.getOffsetNanosecondsFor('2020-08-06T15:00Z'); // => 3600000000000
tz.getOffsetNanosecondsFor('2020-11-06T01:00Z'); // => 0
```

When implementing this method in a custom time zone, note that the absolute value of the returned UTC offset must be smaller than 24 hours (86,400,000,000,000 nanoseconds).
Any time this method is called as part of another Temporal operation, this will be checked, so if your custom time zone returns a longer offset, most built-in time zone operations will not work.

### timeZone.**getOffsetStringFor**(_instant_: Temporal.Instant | string) : string

**Parameters:**
Expand Down
2 changes: 1 addition & 1 deletion polyfill/lib/ecmascript.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5201,6 +5201,7 @@ export function AddDurationToOrSubtractDurationFromPlainYearMonth(operation, yea
}
let { years, months, weeks, days, hours, minutes, seconds, milliseconds, microseconds, nanoseconds } = duration;
({ days } = BalanceTimeDuration(days, hours, minutes, seconds, milliseconds, microseconds, nanoseconds, 'day'));
options = GetOptionsObject(options);
const sign = DurationSign(years, months, weeks, days, 0, 0, 0, 0, 0, 0);

const calendarRec = new CalendarMethodRecord(GetSlot(yearMonth, CALENDAR), [
Expand Down Expand Up @@ -5240,7 +5241,6 @@ export function AddDurationToOrSubtractDurationFromPlainYearMonth(operation, yea
startDate = CalendarDateFromFields(calendarRec, fieldsCopy);
}
const durationToAdd = new Duration(years, months, weeks, days, 0, 0, 0, 0, 0, 0);
options = GetOptionsObject(options);
const optionsCopy = SnapshotOwnProperties(options, null);
const addedDate = AddDate(calendarRec, startDate, durationToAdd, options);
const addedDateFields = PrepareTemporalFields(addedDate, fieldNames, []);
Expand Down
2 changes: 1 addition & 1 deletion polyfill/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"types": "index.d.ts",
"scripts": {
"test": "node --loader ./test/resolve.source.mjs ./test/all.mjs",
"test-cookbook": "npm run build && TEST=all npm run test-cookbook-one && TEST=stockExchangeTimeZone npm run test-cookbook-one",
"test-cookbook": "npm run build && TEST=all npm run test-cookbook-one",
"test-cookbook-one": "node --loader ./test/resolve.cookbook.mjs ../docs/cookbook/$TEST.mjs",
"test262": "npm run build262 && node runtest262.mjs",
"codecov:test262": "./ci_codecov_test262.sh",
Expand Down
2 changes: 1 addition & 1 deletion spec/abstractops.html
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,7 @@ <h1>
</p>
<emu-alg>
1. Let _value_ be ? Get(_options_, *"relativeTo"*).
1. If _value_ is *undefined*, return the Record { [[ZonedRelativeTo]]: *undefined*, [[PlainRelativeTo]]: *undefined* }.
1. If _value_ is *undefined*, return the Record { [[PlainRelativeTo]]: *undefined*, [[ZonedRelativeTo]]: *undefined*, [[TimeZoneRec]]: *undefined* }.
1. Let _offsetBehaviour_ be ~option~.
1. Let _matchBehaviour_ be ~match exactly~.
1. If Type(_value_) is Object, then
Expand Down
4 changes: 1 addition & 3 deletions spec/duration.html
Original file line number Diff line number Diff line change
Expand Up @@ -1528,7 +1528,7 @@ <h1>
<dd>It adds the components of a second duration represented by _y2_ through _ns2_ to those of a first duration represented by _y1_ through _ns1_, and balances the duration relative to the given date _zonedRelativeTo_ or _plainRelativeTo_, to ensure that no mixed signs remain in the result.</dd>
</dl>
<emu-alg>
1. Assert: If _zonedRelativeTo_ is not *undefined*, _calendarRec_ is not *undefined*.
1. Assert: If _zonedRelativeTo_ is not *undefined*, or _plainRelativeTo_ is not *undefined*, _calendarRec_ is not *undefined*.
1. Assert: If _zonedRelativeTo_ is not *undefined*, _timeZoneRec_ is not *undefined*.
1. Let _largestUnit1_ be ! DefaultTemporalLargestUnit(_y1_, _mon1_, _w1_, _d1_, _h1_, _min1_, _s1_, _ms1_, _mus1_).
1. Let _largestUnit2_ be ! DefaultTemporalLargestUnit(_y2_, _mon2_, _w2_, _d2_, _h2_, _min2_, _s2_, _ms2_, _mus2_).
Expand All @@ -1542,8 +1542,6 @@ <h1>
1. Assert: _zonedRelativeTo_ is *undefined*.
1. Let _dateDuration1_ be ! CreateTemporalDuration(_y1_, _mon1_, _w1_, _d1_, 0, 0, 0, 0, 0, 0).
1. Let _dateDuration2_ be ! CreateTemporalDuration(_y2_, _mon2_, _w2_, _d2_, 0, 0, 0, 0, 0, 0).
1. Let _calendarUnitsPresent_ be *true*.
1. If _y1_ = 0 and _mon1_ = 0 and _w1_ = 0 and _y2_ = 0 and _mon2_ = 0 and _w2_ = 0, set _calendarUnitsPresent_ to *false*.
1. Let _intermediate_ be ? AddDate(_calendarRec_, _plainRelativeTo_, _dateDuration1_).
1. Let _end_ be ? AddDate(_calendarRec_, _intermediate_, _dateDuration2_).
1. Let _dateLargestUnit_ be ! LargerOfTwoTemporalUnits(*"day"*, _largestUnit_).
Expand Down
1 change: 1 addition & 0 deletions spec/instant.html
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,7 @@ <h1>ToTemporalInstant ( _item_ )</h1>
1. If _item_ is not a String, throw a *TypeError* exception.
1. Let _parsed_ be ? ParseTemporalInstantString(_item_).
1. If _parsed_.[[Z]] is *true*, let _offsetNanoseconds_ be 0; otherwise, let _offsetNanoseconds_ be ! ParseDateTimeUTCOffset(_parsed_.[[OffsetString]]).
1. If abs(ISODateToEpochDays(_parsed_.[[Year]], _parsed_.[[Month]] - 1, _parsed_.[[Day]])) > 10<sup>8</sup>, throw a *RangeError* exception.
1. Let _epochNanoseconds_ be GetUTCEpochNanoseconds(_parsed_.[[Year]], _parsed_.[[Month]], _parsed_.[[Day]], _parsed_.[[Hour]], _parsed_.[[Minute]], _parsed_.[[Second]], _parsed_.[[Millisecond]], _parsed_.[[Microsecond]], _parsed_.[[Nanosecond]], _offsetNanoseconds_).
1. If IsValidEpochNanoseconds(_epochNanoseconds_) is *false*, throw a *RangeError* exception.
1. Return ! CreateTemporalInstant(_epochNanoseconds_).
Expand Down
1 change: 1 addition & 0 deletions spec/plaindatetime.html
Original file line number Diff line number Diff line change
Expand Up @@ -941,6 +941,7 @@ <h1>
</emu-note>
<emu-alg>
1. Assert: IsValidISODate(_year_, _month_, _day_) is *true*.
1. If abs(ISODateToEpochDays(_year_, _month_ - 1, _day_)) > 10<sup>8</sup> + 1, return *false*.
1. Let _ns_ be ℝ(GetUTCEpochNanoseconds(_year_, _month_, _day_, _hour_, _minute_, _second_, _millisecond_, _microsecond_, _nanosecond_)).
1. If _ns_ &le; nsMinInstant - nsPerDay, then
1. Return *false*.
Expand Down
1 change: 1 addition & 0 deletions spec/plainmonthday.html
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,7 @@ <h1>
1. Let _referenceISOYear_ be 1972 (the first ISO 8601 leap year after the epoch).
1. Return ? CreateTemporalMonthDay(_result_.[[Month]], _result_.[[Day]], _calendar_, _referenceISOYear_).
1. Set _result_ to ? CreateTemporalMonthDay(_result_.[[Month]], _result_.[[Day]], _calendar_, _result_.[[Year]]).
1. Let _calendarRec_ be ! CreateCalendarMethodsRecord(_calendar_, « ~monthDayFromFields~ »).
1. NOTE: The following operation is called without _options_, in order for the calendar to store a canonical value in the [[ISOYear]] internal slot of the result.
1. Return ? CalendarMonthDayFromFields(_calendarRec_, _result_).
</emu-alg>
Expand Down
2 changes: 1 addition & 1 deletion spec/plainyearmonth.html
Original file line number Diff line number Diff line change
Expand Up @@ -676,6 +676,7 @@ <h1>
1. If _operation_ is ~subtract~, then
1. Set _duration_ to ! CreateNegatedTemporalDuration(_duration_).
1. Let _balanceResult_ be ? BalanceTimeDuration(_duration_.[[Days]], _duration_.[[Hours]], _duration_.[[Minutes]], _duration_.[[Seconds]], _duration_.[[Milliseconds]], _duration_.[[Microseconds]], _duration_.[[Nanoseconds]], *"day"*).
1. Set _options_ to ? GetOptionsObject(_options_).
1. Let _sign_ be ! DurationSign(_duration_.[[Years]], _duration_.[[Months]], _duration_.[[Weeks]], _balanceResult_.[[Days]], 0, 0, 0, 0, 0, 0).
1. Let _calendarRec_ be ? CreateCalendarMethodsRecord(_yearMonth_.[[Calendar]], « ~dateAdd~, ~dateFromFields~, ~day~, ~fields~, ~yearMonthFromFields~ »).
1. Let _fieldNames_ be ? CalendarFields(_calendarRec_, « *"monthCode"*, *"year"* »).
Expand All @@ -694,7 +695,6 @@ <h1>
1. Else,
1. Let _date_ be _intermediateDate_.
1. Let _durationToAdd_ be ! CreateTemporalDuration(_duration_.[[Years]], _duration_.[[Months]], _duration_.[[Weeks]], _balanceResult_.[[Days]], 0, 0, 0, 0, 0, 0).
1. Set _options_ to ? GetOptionsObject(_options_).
1. Let _optionsCopy_ be ? SnapshotOwnProperties(_options_, *null*).
1. Let _addedDate_ be ? AddDate(_calendarRec_, _date_, _durationToAdd_, _options_).
1. Let _addedDateFields_ be ? PrepareTemporalFields(_addedDate_, _fieldNames_, «»).
Expand Down
Loading