Skip to content

Commit

Permalink
Updates based on review
Browse files Browse the repository at this point in the history
  • Loading branch information
Aditi-1400 committed Apr 24, 2023
1 parent 9ab873a commit fbe7ef0
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 34 deletions.
Binary file added .DS_Store
Binary file not shown.
2 changes: 1 addition & 1 deletion polyfill/test262
Submodule test262 updated 1426 files
48 changes: 19 additions & 29 deletions spec/abstractops.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ <h1>
<dd>It calculates a number of days.</dd>
</dl>
<emu-alg>
1. Let _ym_ be _year_ + (floor(_month_) / 12).
1. Let _mn_ be _month_ modulo 12.
1. Find a time value _t_ such that EpochTimeToEpochYear(_t_) is _ym_, EpochTimeToMonthInYear(_t_) is _mn_, and EpochTimeToDate(_t_) is 1.
1. Return ℝ(Day(_t_)) + _date_ - 1.
1. Let _resolvedYear_ be _year_ + floor(_month_ / 12).
1. Let _resolvedMonth_ be _month_ modulo 12.
1. Find a time _t_ such that EpochTimeToEpochYear(_t_) is _resolvedYear_, EpochTimeToMonthInYear(_t_) is _resolvedMonth_, and EpochTimeToDate(_t_) is 1.
1. Return EpochTimeToDayNumber(_t_) + _date_ - 1.
</emu-alg>
<emu-note type="editor"> This operation corresponds to ECMA-262 operation MakeDay(_year_, _month_, _date_). It calculates the result in mathematical values instead of Number values. These two operations would be unified when https://github.com/tc39/ecma262/issues/1087 is fixed.</emu-note>
</emu-clause>
Expand All @@ -67,34 +67,31 @@ <h1>
<emu-note type="editor"> This operation corresponds to ECMA-262 operation MakeDate(_date_, _time_). It calculates the result in mathematical values instead of Number values. These two operations would be unified when https://github.com/tc39/ecma262/issues/1087 is fixed.</emu-note>
</emu-clause>

<emu-clause id="sec-year-number">
<h1>Year Number</h1>
<p>ECMAScript uses a proleptic Gregorian calendar to map a day number to a year number and to determine the month and date within that year. In this calendar, leap years are precisely those which are (divisible by 4) and ((not divisible by 100) or (divisible by 400)). The number of days in year number _y_ is therefore defined by</p>
<emu-clause id="sec-date-equations">
<h1>Date Equations</h1>
<p>A given time _t_ belongs to day number</p>
<emu-eqn id="eqn-EpochTimeToDayNumber" aoid="EpochTimeToDayNumber">EpochTimeToDayNumber(_t_) = floor(_t_ / ℝ(msPerDay))</emu-eqn>
<p>Number of days in year are given by:</p>
<emu-eqn id="eqn-mathematicaldaysinyear" aoid="MathematicalDaysInYear">
MathematicalDaysInYear(_y_)
= 365 if ((_y_) modulo 4) ≠ 0
= 366 if ((_y_) modulo 4) = 0 and ((_y_) modulo 100) ≠ 0
= 365 if ((_y_) modulo 100) = 0 and ((_y_) modulo 400) ≠ 0
= 366 if ((_y_) modulo 400) = 0
</emu-eqn>
<p>All non-leap years have 365 days with the usual number of days per month and leap years have an extra day in February. The day number of the first day of year _y_ is given by:</p>
<p>The day number of the first day of year _y_ is given by:</p>
<emu-eqn id="eqn-epochdaynumberforyear" aoid="EpochDayNumberForYear">EpochDayNumberForYear(_y_) = 365 × (_y_ - 1970) + floor((_y_ - 1969) / 4) - floor((_y_ - 1901) / 100) + floor((_y_ - 1601) / 400)</emu-eqn>
<p>The time of the start of a year is:</p>
<emu-eqn id="eqn-epochtimeforyear" aoid="EpochTimeForYear">EpochTimeForYear(_y_) = ℝ(msPerDay) × EpochDayNumberForYear(_y_)</emu-eqn>
<p>A time value determines a year by:</p>
<p>Epoch year from time _t_ is given by:</p>
<emu-eqn id="eqn-epochtimetoepochyear" aoid="EpochTimeToEpochYear">EpochTimeToEpochYear(_t_) = the largest integral Number _y_ (closest to +∞) such that EpochTimeForYear(_y_) ≤ _t_</emu-eqn>
<p>The leap-year function is 1 for a time within a leap year and otherwise is 0:</p>
<p>The following function returns 1 for a time within leap year otherwise it returns 0:</p>
<emu-eqn id="eqn-mathematicalinleapyear" aoid="MathematicalInLeapYear">
MathematicalInLeapYear(_t_)
= 0 if MathematicalDaysInYear(EpochTimeToEpochYear(_t_)) is 365
= 1 if MathematicalDaysInYear(EpochTimeToEpochYear(_t_)) is 366
</emu-eqn>
<emu-note type="editor"> These operations correspond to ECMA-262 operations DaysInYear(_y_), DayFromYear(_y_), TimeFromYear(_y_), YearFromTime(_t_). They calculate the result in mathematical values instead of Number values. These operations would be unified when https://github.com/tc39/ecma262/issues/1087 is fixed.</emu-note>
</emu-clause>

<emu-clause id="sec-month-number">
<h1>Month Number</h1>
<p>Months are identified by an integer in the inclusive interval from 0 to 11. The mapping EpochTimeToMonthInYear(_t_) from a time value _t_ to a month number is defined by:</p>
<p>The month number for a time _t_ is given by:</p>
<emu-eqn id="eqn-epochtimetomonthinyear" aoid="EpochTimeToMonthInYear">
EpochTimeToMonthInYear(_t_)
= 0 if 0 ≤ EpochTimeToDayInYear(_t_) &lt; 31
Expand All @@ -111,13 +108,9 @@ <h1>Month Number</h1>
= 11 if 334 + MathematicalInLeapYear(_t_) ≤ EpochTimeToDayInYear(_t_) &lt; 365 + MathematicalInLeapYear(_t_)
</emu-eqn>
<p>where</p>
<emu-eqn id="eqn-epochtimetodayinyear" aoid="EpochTimeToDayInYear">EpochTimeToDayInYear(_t_) = ℝ(Day(_t_)) - EpochDayNumberForYear(EpochTimeToEpochYear(_t_))</emu-eqn>
<emu-eqn id="eqn-epochtimetodayinyear" aoid="EpochTimeToDayInYear">EpochTimeToDayInYear(_t_) = EpochTimeToDayNumber(_t_) - EpochDayNumberForYear(EpochTimeToEpochYear(_t_))</emu-eqn>
<p>A month value of 0 specifies January; 1 specifies February; 2 specifies March; 3 specifies April; 4 specifies May; 5 specifies June; 6 specifies July; 7 specifies August; 8 specifies September; 9 specifies October; 10 specifies November; and 11 specifies December. Note that <emu-eqn>EpochTimeToMonthInYear(0) = 0</emu-eqn>, corresponding to Thursday, 1 January 1970.</p>
<emu-note type="editor"> These operations correspond to ECMA-262 operations MonthFromTime(_t_) and DayWithinYear(_y_). They calculate the result in mathematical values instead of Number values. Also note that this operation uses 0-based months unlike rest of Temporal since we intend for it to be merged back into the original one when https://github.com/tc39/ecma262/issues/1087 is fixed.</emu-note>
</emu-clause>
<emu-clause id="sec-date-number">
<h1>Date Number</h1>
<p>A date number is identified by a mathematical value in the inclusive interval from 1 to 31. The mapping EpochTimeToDate(_t_) from a time value _t_ to a date number is defined by:</p>
<p>The date number for a time _t_ is given by:</p>
<emu-eqn id="eqn-epochtimetodate" aoid="EpochTimeToDate">
EpochTimeToDate(_t_)
= EpochTimeToDayInYear(_t_) + 1 if EpochTimeToMonthInYear(_t_) is 0
Expand All @@ -133,14 +126,11 @@ <h1>Date Number</h1>
= EpochTimeToDayInYear(_t_) - 303 - MathematicalInLeapYear(_t_) if EpochTimeToMonthInYear(_t_) is 10
= EpochTimeToDayInYear(_t_) - 333 - MathematicalInLeapYear(_t_) if EpochTimeToMonthInYear(_t_) is 11
</emu-eqn>
<emu-note type="editor"> This operation corresponds to ECMA-262 operation DateFromTime(_t_). It calculates the result in mathematical values instead of Number values. These operations would be unified when https://github.com/tc39/ecma262/issues/1087 is fixed.</emu-note>
</emu-clause>
<emu-clause id="sec-week-day">
<h1>Week Day</h1>
<p>The weekday for a particular time _t_ is defined as</p>
<emu-eqn id="eqn-epochtimetoweekday" aoid="EpochTimeToWeekDay">EpochTimeToWeekDay(_t_) =(ℝ(Day(_t_)) + 4) modulo 7</emu-eqn>
<p>The weekday for a particular time _t_ is defined as:</p>
<emu-eqn id="eqn-epochtimetoweekday" aoid="EpochTimeToWeekDay">EpochTimeToWeekDay(_t_) =(EpochTimeToDayNumber(_t_) + 4) modulo 7</emu-eqn>
<p>A weekday value of 0 specifies Sunday; 1 specifies Monday; 2 specifies Tuesday; 3 specifies Wednesday; 4 specifies Thursday; 5 specifies Friday; and 6 specifies Saturday. Note that <emu-eqn>EpochTimeToWeekDay(0) = 4</emu-eqn>, corresponding to Thursday, 1 January 1970.</p>
<emu-note type="editor"> This operation corresponds to ECMA-262 operation WeekDay(_t_). It calculates the result in mathematical values instead of Number values. These operations would be unified when https://github.com/tc39/ecma262/issues/1087 is fixed.</emu-note>
<emu-note type="editor"> These equations correspond to ECMA-262 equations defined in <emu-xref href="#sec-year-number">Year Number</emu-xref>, <emu-xref href="#sec-month-number">Month Number</emu-xref>, <emu-xref href="#sec-date-number">Date Number</emu-xref>, <emu-xref href="#sec-week-day">Week Day</emu-xref> respectively. These calculate the result in mathematical values instead of Number values. These equations would be unified when https://github.com/tc39/ecma262/issues/1087 is fixed.</emu-note>
<emu-note type="editor"> Note that the operation EpochTimeToMonthInYear(_t_) uses 0-based months unlike rest of Temporal since it's intended to be unified with MonthFromTime(_t_) when the above mentioned issue is fixed.</emu-note>
</emu-clause>
<!-- Copied from ECMA-402 GetOptionsObject -->
<emu-clause id="sec-getoptionsobject" aoid="GetOptionsObject">
Expand Down
9 changes: 8 additions & 1 deletion spec/intl.html
Original file line number Diff line number Diff line change
Expand Up @@ -1033,7 +1033,14 @@ <h1>ToLocalTime ( _t_, _calendar_, _timeZone_ )</h1>
</td>
</tr>
<tr>
<h1>ToLocalTime ( _t_, _calendar_, _timeZone_ )</h1>
<td>[[RelatedYear]]</td>
<td>*undefined*</td>
</tr>
<tr>
<td>[[YearName]]</td>
<td>*undefined*</td>
</tr>
<tr>
<td>[[Month]]</td>
<td>
<del>`MonthFromTime(tz)` specified in ES2023's <emu-xref href="#sec-month-number">Month Number</emu-xref></del>
Expand Down
6 changes: 3 additions & 3 deletions spec/timezone.html
Original file line number Diff line number Diff line change
Expand Up @@ -420,9 +420,9 @@ <h1>
1. Assert: ! IsValidEpochNanoseconds(ℤ(_epochNanoseconds_)) is *true*.
1. Let _remainderNs_ be _epochNanoseconds_ modulo 10<sup>6</sup>.
1. Let _epochMilliseconds_ be 𝔽((_epochNanoseconds_ - _remainderNs_) / 10<sup>6</sup>).
1. Let _year_ be ! EpochTimeToEpochYear(_epochMilliseconds_).
1. Let _month_ be ! EpochTimeToMonthInYear(_epochMilliseconds_) + 1.
1. Let _day_ be ! EpochTimeToDate(_epochMilliseconds_).
1. Let _year_ be EpochTimeToEpochYear(_epochMilliseconds_).
1. Let _month_ be EpochTimeToMonthInYear(_epochMilliseconds_) + 1.
1. Let _day_ be EpochTimeToDate(_epochMilliseconds_).
1. Let _hour_ be ℝ(! HourFromTime(_epochMilliseconds_)).
1. Let _minute_ be ℝ(! MinFromTime(_epochMilliseconds_)).
1. Let _second_ be ℝ(! SecFromTime(_epochMilliseconds_)).
Expand Down

0 comments on commit fbe7ef0

Please sign in to comment.