-
Notifications
You must be signed in to change notification settings - Fork 163
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
Polyfill: Fix daysInYear and inLeapYear in Islamic calendars #2743
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #2743 +/- ##
==========================================
+ Coverage 96.38% 96.73% +0.35%
==========================================
Files 21 21
Lines 12444 12444
Branches 2250 2255 +5
==========================================
+ Hits 11994 12038 +44
+ Misses 395 349 -46
- Partials 55 57 +2 ☔ View full report in Codecov by Sentry. |
2201be4
to
f733e9b
Compare
Tests the changes in tc39/proposal-temporal#2743.
Great |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems correct to me. I will try to review the tests soon. BTW, it seems like the new tests are not covering dayOfYear
and that's partly why codecov is complaining, but I don't understand why it's also complaining about inLeapYear
since the tests are definitely covering that.
@justingrant as pointed out by @ptomato, the The day of the year ordinal integer is the difference in days between the date in question and the start of the year of that date + 1. |
Oh! I'll take a look. |
Tests the changes in tc39/proposal-temporal#2743
f733e9b
to
37f75d6
Compare
Tests the changes in tc39/proposal-temporal#2743
37f75d6
to
dee9ed5
Compare
Tests the changes in tc39/proposal-temporal#2743
dee9ed5
to
ff85f40
Compare
Tests the changes in tc39/proposal-temporal#2743
ff85f40
to
19db917
Compare
I added tests for @MohsenAlyafei could you provide an example test case where the code in this PR doesn't correctly calculate Note that the Temporal polyfill uses |
Tests the changes in tc39/proposal-temporal#2743
Tests the changes in tc39/proposal-temporal#2743
19db917
to
59f8cae
Compare
d = Temporal.PlainDate.from({year:1445, month:1, day:1, calendar:'islamic-umalqura'})
// => Temporal.PlainDate <2023-07-19[u-ca=islamic-umalqura]>
d.dayOfYear
// => 1
d.subtract({days:1}).dayOfYear
// => 354 |
Fixes #2740. There were two separate problems with the islamic calendar implementation in the Temporal polyfill, both fixed in this PR:
islamic-umalqura
calendar appears to break this rule. New implementation calculates the number of days in the year; if 355 then it's a leap year.daysInYear
.