mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-07 00:29:15 +00:00
LibJS: Implement Temporal.PlainMonthDay.prototype.with/equals
This commit is contained in:
parent
5bccb36a6f
commit
5389acc231
Notes:
github-actions[bot]
2024-11-22 00:25:30 +00:00
Author: https://github.com/trflynn89
Commit: 5389acc231
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2471
10 changed files with 314 additions and 0 deletions
|
@ -113,4 +113,35 @@ bool iso_date_within_limits(ISODate iso_date)
|
|||
return iso_date_time_within_limits(iso_date_time);
|
||||
}
|
||||
|
||||
// 3.5.12 CompareISODate ( isoDate1, isoDate2 ), https://tc39.es/proposal-temporal/#sec-temporal-compareisodate
|
||||
i8 compare_iso_date(ISODate iso_date1, ISODate iso_date2)
|
||||
{
|
||||
// 1. If isoDate1.[[Year]] > isoDate2.[[Year]], return 1.
|
||||
if (iso_date1.year > iso_date2.year)
|
||||
return 1;
|
||||
|
||||
// 2. If isoDate1.[[Year]] < isoDate2.[[Year]], return -1.
|
||||
if (iso_date1.year < iso_date2.year)
|
||||
return -1;
|
||||
|
||||
// 3. If isoDate1.[[Month]] > isoDate2.[[Month]], return 1.
|
||||
if (iso_date1.month > iso_date2.month)
|
||||
return 1;
|
||||
|
||||
// 4. If isoDate1.[[Month]] < isoDate2.[[Month]], return -1.
|
||||
if (iso_date1.month < iso_date2.month)
|
||||
return -1;
|
||||
|
||||
// 5. If isoDate1.[[Day]] > isoDate2.[[Day]], return 1.
|
||||
if (iso_date1.day > iso_date2.day)
|
||||
return 1;
|
||||
|
||||
// 6. If isoDate1.[[Day]] < isoDate2.[[Day]], return -1.
|
||||
if (iso_date1.day < iso_date2.day)
|
||||
return -1;
|
||||
|
||||
// 7. Return 0.
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue