mirror of
https://github.com/Samsung/escargot.git
synced 2026-06-22 10:01:50 +00:00
Fix extended year bug with iso8601 calendar
Signed-off-by: Seonghyun Kim <sh8281.kim@samsung.com>
This commit is contained in:
parent
ee64383623
commit
71706514f4
4 changed files with 21 additions and 25 deletions
|
|
@ -240,6 +240,9 @@ bool Calendar::isEraRelated() const
|
|||
|
||||
bool Calendar::shouldUseICUExtendedYear() const
|
||||
{
|
||||
if (id() == Calendar::ID::ISO8601) {
|
||||
return true;
|
||||
}
|
||||
if (sameAsGregoryExceptHandlingEraAndYear()) {
|
||||
return false;
|
||||
}
|
||||
|
|
@ -3495,14 +3498,13 @@ std::pair<UCalendar*, ISO8601::PlainDate> Temporal::calendarDateAdd(ExecutionSta
|
|||
|
||||
return std::make_pair(newCal.release(), ISO8601::PlainDate(year, month, day));
|
||||
} else {
|
||||
int32_t y, m, d, check, monthCount;
|
||||
int32_t y, m, d, check;
|
||||
MonthCode mc;
|
||||
|
||||
y = ucal_get(newCal.get(), UCAL_YEAR, &status);
|
||||
m = calendar.ordinalMonth(state, newCal.get());
|
||||
mc = calendar.monthCode(state, newCal.get());
|
||||
d = ucal_get(newCal.get(), UCAL_DAY_OF_MONTH, &status);
|
||||
monthCount = TemporalPlainDateGetter::monthsInYear(state, computeISODate(state, newCal.get()), calendar, newCal.get()).asInt32();
|
||||
|
||||
bool isAnnotherCaseOfCalendarsItHasLeapMonth = (calendar.id() == Calendar::ID::Chinese || calendar.id() == Calendar::ID::Dangi);
|
||||
bool isHebrewRejectCase = overflow == TemporalOverflowOption::Reject && calendar.id() == Calendar::ID::Hebrew && duration.years() && mc.isLeapMonth;
|
||||
|
|
@ -3689,7 +3691,7 @@ ISO8601::Duration Temporal::calendarDateUntil(ExecutionState& state, Calendar ca
|
|||
CHECK_ICU_CALENDAR();
|
||||
|
||||
if (largestUnit == TemporalUnit::Year) {
|
||||
years = ucal_getFieldDifference(calOne.get(), twoEpoch, UCAL_YEAR, &status);
|
||||
years = ucal_getFieldDifference(calOne.get(), twoEpoch, UCAL_EXTENDED_YEAR, &status);
|
||||
CHECK_ICU_CALENDAR();
|
||||
if (years) {
|
||||
oneEpoch = ucal_getMillis(calOne.get(), &status);
|
||||
|
|
|
|||
|
|
@ -492,12 +492,17 @@ TemporalPlainDateObject* TemporalPlainDateObject::with(ExecutionState& state, Va
|
|||
TemporalPlainDateObject* TemporalPlainDateObject::withCalendar(ExecutionState& state, Value calendarLike)
|
||||
{
|
||||
auto calendar = Temporal::toTemporalCalendarIdentifier(state, calendarLike);
|
||||
auto icuCalendar = calendar.createICUCalendar(state);
|
||||
LocalResourcePointer<UCalendar> newCal(calendar.createICUCalendar(state), [](UCalendar* r) {
|
||||
ucal_close(r);
|
||||
});
|
||||
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
ucal_setMillis(icuCalendar, ucal_getMillis(m_icuCalendar, &status), &status);
|
||||
auto epoch = ucal_getMillis(m_icuCalendar, &status);
|
||||
CHECK_ICU()
|
||||
ucal_setMillis(newCal.get(), epoch, &status);
|
||||
CHECK_ICU()
|
||||
|
||||
return new TemporalPlainDateObject(state, state.context()->globalObject()->temporalPlainDatePrototype(), std::make_pair(icuCalendar, NullOption), calendar);
|
||||
return new TemporalPlainDateObject(state, state.context()->globalObject()->temporalPlainDatePrototype(), std::make_pair(newCal.release(), NullOption), calendar);
|
||||
}
|
||||
|
||||
TemporalDurationObject* TemporalPlainDateObject::since(ExecutionState& state, Value other, Value options)
|
||||
|
|
|
|||
|
|
@ -236,14 +236,19 @@ TemporalPlainDateTimeObject* TemporalPlainDateTimeObject::withCalendar(Execution
|
|||
{
|
||||
// Let calendar be ? ToTemporalCalendarIdentifier(calendarLike).
|
||||
auto calendar = Temporal::toTemporalCalendarIdentifier(state, calendarLike);
|
||||
auto icuCalendar = calendar.createICUCalendar(state);
|
||||
LocalResourcePointer<UCalendar> newCal(calendar.createICUCalendar(state), [](UCalendar* r) {
|
||||
ucal_close(r);
|
||||
});
|
||||
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
ucal_setMillis(icuCalendar, ucal_getMillis(m_icuCalendar, &status), &status);
|
||||
auto epoch = ucal_getMillis(m_icuCalendar, &status);
|
||||
CHECK_ICU()
|
||||
ucal_setMillis(newCal.get(), epoch, &status);
|
||||
CHECK_ICU()
|
||||
|
||||
// Return ! CreateTemporalDateTime(plainDateTime.[[ISODateTime]], calendar).
|
||||
return new TemporalPlainDateTimeObject(state, state.context()->globalObject()->temporalPlainDateTimePrototype(),
|
||||
icuCalendar, plainTime().microsecond() * 1000 + plainTime().nanosecond(), calendar);
|
||||
newCal.release(), plainTime().microsecond() * 1000 + plainTime().nanosecond(), calendar);
|
||||
}
|
||||
|
||||
TemporalPlainDateTimeObject* TemporalPlainDateTimeObject::addDurationToDateTime(ExecutionState& state, AddDurationToDateTimeOperation operation, Value temporalDurationLike, Value options)
|
||||
|
|
|
|||
|
|
@ -318,8 +318,6 @@
|
|||
<test id="built-ins/Temporal/Duration/prototype/total/rounding-window"><reason>TODO</reason></test>
|
||||
<test id="built-ins/Temporal/Instant/prototype/round/negative-instant"><reason>TODO</reason></test>
|
||||
<test id="built-ins/Temporal/Instant/prototype/toString/negative-instant-rounding"><reason>TODO</reason></test>
|
||||
<test id="built-ins/Temporal/PlainDate/prototype/add/argument-duration-max"><reason>TODO</reason></test>
|
||||
<test id="built-ins/Temporal/PlainDate/prototype/subtract/argument-duration-max"><reason>TODO</reason></test>
|
||||
<test id="built-ins/Temporal/PlainDate/prototype/with/overflow"><reason>TODO</reason></test>
|
||||
<test id="built-ins/Temporal/PlainDate/prototype/with/overflow-undefined"><reason>TODO</reason></test>
|
||||
<test id="built-ins/Temporal/PlainDateTime/prototype/since/options-read-before-algorithmic-validation"><reason>TODO</reason></test>
|
||||
|
|
@ -327,8 +325,6 @@
|
|||
<test id="built-ins/Temporal/PlainDateTime/prototype/toString/rounding-edge-of-range"><reason>TODO</reason></test>
|
||||
<test id="built-ins/Temporal/PlainDateTime/prototype/until/options-read-before-algorithmic-validation"><reason>TODO</reason></test>
|
||||
<test id="built-ins/Temporal/PlainDateTime/prototype/until/order-of-operations"><reason>TODO</reason></test>
|
||||
<test id="built-ins/Temporal/PlainYearMonth/prototype/add/argument-duration-max"><reason>TODO</reason></test>
|
||||
<test id="built-ins/Temporal/PlainYearMonth/prototype/subtract/argument-duration-max"><reason>TODO</reason></test>
|
||||
<test id="built-ins/Temporal/PlainYearMonth/prototype/with/options-read-before-algorithmic-validation"><reason>TODO</reason></test>
|
||||
<test id="built-ins/Temporal/ZonedDateTime/compare/argument-string-limits"><reason>TODO</reason></test>
|
||||
<test id="built-ins/Temporal/ZonedDateTime/from/argument-string-limits"><reason>TODO</reason></test>
|
||||
|
|
@ -417,9 +413,6 @@
|
|||
<test id="intl402/Temporal/PlainDate/from/islamic-rgsa"><reason>TODO</reason></test>
|
||||
<test id="intl402/Temporal/PlainDate/prototype/add/leap-year-persian"><reason>TODO</reason></test>
|
||||
<test id="intl402/Temporal/PlainDate/prototype/monthCode/chinese-calendar-dates"><reason>TODO</reason></test>
|
||||
<test id="intl402/Temporal/PlainDate/prototype/since/era-boundary-ethiopic"><reason>TODO</reason></test>
|
||||
<test id="intl402/Temporal/PlainDate/prototype/since/era-boundary-gregory"><reason>TODO</reason></test>
|
||||
<test id="intl402/Temporal/PlainDate/prototype/since/era-boundary-japanese"><reason>TODO</reason></test>
|
||||
<test id="intl402/Temporal/PlainDate/prototype/since/intercalary-month-coptic"><reason>TODO</reason></test>
|
||||
<test id="intl402/Temporal/PlainDate/prototype/since/intercalary-month-ethioaa"><reason>TODO</reason></test>
|
||||
<test id="intl402/Temporal/PlainDate/prototype/since/intercalary-month-ethiopic"><reason>TODO</reason></test>
|
||||
|
|
@ -440,9 +433,6 @@
|
|||
<test id="intl402/Temporal/PlainDate/prototype/since/wrapping-at-end-of-month-persian"><reason>TODO</reason></test>
|
||||
<test id="intl402/Temporal/PlainDate/prototype/subtract/leap-year-persian"><reason>TODO</reason></test>
|
||||
<test id="intl402/Temporal/PlainDate/prototype/toZonedDateTime/dst-skipped-cross-midnight"><reason>TODO</reason></test>
|
||||
<test id="intl402/Temporal/PlainDate/prototype/until/era-boundary-ethiopic"><reason>TODO</reason></test>
|
||||
<test id="intl402/Temporal/PlainDate/prototype/until/era-boundary-gregory"><reason>TODO</reason></test>
|
||||
<test id="intl402/Temporal/PlainDate/prototype/until/era-boundary-japanese"><reason>TODO</reason></test>
|
||||
<test id="intl402/Temporal/PlainDate/prototype/until/intercalary-month-coptic"><reason>TODO</reason></test>
|
||||
<test id="intl402/Temporal/PlainDate/prototype/until/intercalary-month-ethioaa"><reason>TODO</reason></test>
|
||||
<test id="intl402/Temporal/PlainDate/prototype/until/intercalary-month-ethiopic"><reason>TODO</reason></test>
|
||||
|
|
@ -522,9 +512,6 @@
|
|||
<test id="intl402/Temporal/PlainDateTime/from/islamic-rgsa"><reason>TODO</reason></test>
|
||||
<test id="intl402/Temporal/PlainDateTime/prototype/add/leap-year-persian"><reason>TODO</reason></test>
|
||||
<test id="intl402/Temporal/PlainDateTime/prototype/monthCode/chinese-calendar-dates"><reason>TODO</reason></test>
|
||||
<test id="intl402/Temporal/PlainDateTime/prototype/since/era-boundary-ethiopic"><reason>TODO</reason></test>
|
||||
<test id="intl402/Temporal/PlainDateTime/prototype/since/era-boundary-gregory"><reason>TODO</reason></test>
|
||||
<test id="intl402/Temporal/PlainDateTime/prototype/since/era-boundary-japanese"><reason>TODO</reason></test>
|
||||
<test id="intl402/Temporal/PlainDateTime/prototype/since/intercalary-month-coptic"><reason>TODO</reason></test>
|
||||
<test id="intl402/Temporal/PlainDateTime/prototype/since/intercalary-month-ethioaa"><reason>TODO</reason></test>
|
||||
<test id="intl402/Temporal/PlainDateTime/prototype/since/intercalary-month-ethiopic"><reason>TODO</reason></test>
|
||||
|
|
@ -547,9 +534,6 @@
|
|||
<test id="intl402/Temporal/PlainDateTime/prototype/toZonedDateTime/dst-disambiguation"><reason>TODO</reason></test>
|
||||
<test id="intl402/Temporal/PlainDateTime/prototype/toZonedDateTime/multiple-instants"><reason>TODO</reason></test>
|
||||
<test id="intl402/Temporal/PlainDateTime/prototype/toZonedDateTime/order-of-operations"><reason>TODO</reason></test>
|
||||
<test id="intl402/Temporal/PlainDateTime/prototype/until/era-boundary-ethiopic"><reason>TODO</reason></test>
|
||||
<test id="intl402/Temporal/PlainDateTime/prototype/until/era-boundary-gregory"><reason>TODO</reason></test>
|
||||
<test id="intl402/Temporal/PlainDateTime/prototype/until/era-boundary-japanese"><reason>TODO</reason></test>
|
||||
<test id="intl402/Temporal/PlainDateTime/prototype/until/intercalary-month-coptic"><reason>TODO</reason></test>
|
||||
<test id="intl402/Temporal/PlainDateTime/prototype/until/intercalary-month-ethioaa"><reason>TODO</reason></test>
|
||||
<test id="intl402/Temporal/PlainDateTime/prototype/until/intercalary-month-ethiopic"><reason>TODO</reason></test>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue