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

Eliminate duplication between Duration Records and Temporal.Duration instances #2943

Merged
merged 26 commits into from
Sep 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
730e676
Editorial: Refactor TemporalDurationToString to take a Duration instance
ptomato Sep 13, 2024
a7ddf73
Editorial: Refactor DurationSign to take a Duration instance
ptomato Sep 16, 2024
04930dc
Editorial: Refactor UnbalanceDateDurationRelative to take a Date Dura…
ptomato Sep 16, 2024
a7c6db7
Editorial: Refactor CombineDateAndNormalizedTimeDuration to take a Da…
ptomato Sep 17, 2024
21508f5
Editorial: Refactor DifferenceTemporal___ methods to use CreateNegated
ptomato Sep 17, 2024
24b02f2
Editorial: Refactor AddISODate to take a Date Duration Record
ptomato Sep 17, 2024
1c4d5d1
Editorial: Refactor duration adding operations to use CreateNegated
ptomato Sep 17, 2024
f05bf31
Editorial: Refactor AddDateTime to take a Date Duration Record
ptomato Sep 17, 2024
cb6b3b4
Editorial: Refactor Normalized Duration Record to have two fields
ptomato Sep 17, 2024
159ef2e
Editorial: Refactor Duration.p.add/subtract to normalize-calculate-un…
ptomato Sep 17, 2024
2b64158
Editorial: Refactor Duration.p.round/total/toString to use normalize-…
ptomato Sep 18, 2024
a85f9af
Editorial: Refactor Duration.compare to use normalize-calc-unnormalize
ptomato Sep 19, 2024
3a5b8d2
Editorial: Refactor Instant.p.add/subtract to use normalize-calc-unno…
ptomato Sep 19, 2024
9d55d01
Editorial: Refactor PlainDate.p.add/subtract to use normalize-calc-un…
ptomato Sep 19, 2024
403234f
Editorial: Refactor PlainDateTime.p.add/subtract to use normalize-cal…
ptomato Sep 19, 2024
6f37e7f
Editorial: Refactor PlainTime.p.add/subtract to use normalize-calculate
ptomato Sep 19, 2024
2b4a8c8
Editorial: Refactor PlainYearMonth.p.add/subtract to use normalize-ca…
ptomato Sep 19, 2024
2613c40
Editorial: Refactor ZonedDateTime.p.add/subtract to use normalize-cal…
ptomato Sep 19, 2024
0065885
Editorial: Refactor Instant.p.since/until to use normalize-calculate-…
ptomato Sep 19, 2024
6588998
Editorial: Refactor ZonedDateTime.p.since/until to use normalize-calc…
ptomato Sep 19, 2024
e3a04d9
Editorial: Add NormalizeDurationWithoutTime AO
ptomato Sep 19, 2024
9ab7989
Editorial: Remove BalanceTimeDuration AO and Time Duration Record
ptomato Sep 19, 2024
2ade615
Editorial: Add use of ZeroDateDuration
ptomato Sep 19, 2024
5593091
Editorial: Add AdjustDateDurationRecord AO
ptomato Sep 20, 2024
3333f8e
Editorial: Fix return type of DifferenceISODateTime
ptomato Sep 20, 2024
4cbf8c0
Editorial: Remove Duration Records
ptomato Sep 20, 2024
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
13 changes: 10 additions & 3 deletions polyfill/lib/calendar.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,14 @@ impl['iso8601'] = {
return arrayFromSet(result);
},
dateAdd({ year, month, day }, { years = 0, months = 0, weeks = 0, days = 0 }, overflow) {
return ES.AddISODate(year, month, day, years, months, weeks, days, overflow);
year += years;
month += months;
({ year, month } = ES.BalanceISOYearMonth(year, month));
({ year, month, day } = ES.RegulateISODate(year, month, day, overflow));
day += days + 7 * weeks;
({ year, month, day } = ES.BalanceISODate(year, month, day));
ES.RejectDateRange(year, month, day);
return { year, month, day };
},
dateUntil(one, two, largestUnit) {
return ES.DifferenceISODate(one.year, one.month, one.day, two.year, two.month, two.day, largestUnit);
Expand Down Expand Up @@ -722,7 +729,7 @@ const nonIsoHelperBase = {
return this.isoToCalendarDate(isoDate, cache);
},
addDaysIso(isoDate, days) {
const added = ES.AddISODate(isoDate.year, isoDate.month, isoDate.day, 0, 0, 0, days, 'constrain');
const added = ES.BalanceISODate(isoDate.year, isoDate.month, isoDate.day + days);
return added;
},
addDaysCalendar(calendarDate, days, cache) {
Expand Down Expand Up @@ -1174,7 +1181,7 @@ const helperIndian = ObjectAssign({}, nonIsoHelperBase, {
const isoYear = calendarDate.year + 78 + (monthInfo.nextYear ? 1 : 0);
const isoMonth = monthInfo.month;
const isoDay = monthInfo.day;
const isoDate = ES.AddISODate(isoYear, isoMonth, isoDay, 0, 0, 0, calendarDate.day - 1, 'constrain');
const isoDate = ES.BalanceISODate(isoYear, isoMonth, isoDay + calendarDate.day - 1);
return isoDate;
},
// https://bugs.chromium.org/p/v8/issues/detail?id=10529 causes Intl's Indian
Expand Down
Loading
Loading