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

Calendar.fields method #1014

Merged
merged 3 commits into from
Oct 23, 2020
Merged

Calendar.fields method #1014

merged 3 commits into from
Oct 23, 2020

Conversation

ptomato
Copy link
Collaborator

@ptomato ptomato commented Oct 19, 2020

Closes: #666

@codecov
Copy link

codecov bot commented Oct 19, 2020

Codecov Report

Merging #1014 into main will decrease coverage by 0.08%.
The diff coverage is 90.78%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1014      +/-   ##
==========================================
- Coverage   94.38%   94.30%   -0.09%     
==========================================
  Files          18       18              
  Lines        6556     6657     +101     
  Branches      983      998      +15     
==========================================
+ Hits         6188     6278      +90     
- Misses        361      372      +11     
  Partials        7        7              
Flag Coverage Δ
#test262 48.05% <73.50%> (+0.45%) ⬆️
#tests 90.43% <84.21%> (-0.12%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
polyfill/lib/datetime.mjs 94.98% <66.66%> (-0.26%) ⬇️
polyfill/lib/date.mjs 91.96% <83.33%> (-0.19%) ⬇️
polyfill/lib/ecmascript.mjs 95.98% <91.01%> (-0.20%) ⬇️
polyfill/lib/calendar.mjs 75.50% <100.00%> (+0.31%) ⬆️
polyfill/lib/monthday.mjs 92.76% <100.00%> (+0.24%) ⬆️
polyfill/lib/yearmonth.mjs 95.10% <100.00%> (+0.14%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 43b8373...292b17f. Read the comment docs.

@ptomato
Copy link
Collaborator Author

ptomato commented Oct 19, 2020

Sorry for the noise. This seems to mysteriously fail the test suite with no message (even though all the tests pass). I will investigate this before re-requesting review.

@ptomato ptomato force-pushed the 666-calendar-fields branch from 744711a to 113fa29 Compare October 19, 2020 17:18
@ptomato
Copy link
Collaborator Author

ptomato commented Oct 19, 2020

demitasse seems to swallow exceptions in after() blocks, they still fail the test suite, but print no message. I've fixed the exception now, it's ready for review again.

@pipobscure I don't have time right now to investigate whether this still happens in demitasse 2.x, so I'm inclined to leave it, but if you prefer I can open an issue in demitasse so it doesn't get lost.

@ptomato ptomato marked this pull request as ready for review October 19, 2020 17:20
@ptomato ptomato requested a review from pipobscure October 19, 2020 17:20
docs/calendar.md Show resolved Hide resolved
@pipobscure
Copy link
Collaborator

@pipobscure I don't have time right now to investigate whether this still happens in demitasse 2.x, so I'm inclined to leave it, but if you prefer I can open an issue in demitasse so it doesn't get lost.

Please do. I have to go over that in a few weeks; so I’ll certainly have forgotten this by then.

polyfill/lib/date.mjs Outdated Show resolved Hide resolved
polyfill/lib/date.mjs Outdated Show resolved Hide resolved
Comment on lines 286 to 294
const fields = ES.ToTemporalDateFields(this, calendar);
fields.calendar = calendar;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if fields() returns "calendar" as one of the fields?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure what should be done in that case; I guess one option is to throw if calendar is returned in the validation step I mentioned in #1014 (comment). The other option is to 🤷 and say "well, don't do that then." I'm mildly in favour of the latter since I think it's in line with what we do elsewhere for custom calendars and time zones.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#1047

polyfill/lib/ecmascript.mjs Outdated Show resolved Hide resolved
polyfill/lib/ecmascript.mjs Outdated Show resolved Hide resolved
Comment on lines +727 to +748
1. If _property_ is not *"era"*, then
1. Let _value_ be ? ToInteger(_value_).
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes no sense to me: this would convert any custom property to an integer?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is what I intended. The alternative is to treat any custom property just like era and leave it unchanged. My reasoning was that we wouldn't want to encourage more non-numerical properties like era, but I don't have a strong opinion on which is correct.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We shouldn't assert a particular type on custom properties, except perhaps requiring that it is a primitive.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have a clear idea of the use case of this feature, but this seems to make it impossible to use non-integer properties, rather than just discourage. I'll merge now in the interest of moving forward, but filed #1045.

These are not done yet, but in order for the spec changes for the fields()
method to make sense, they at least need to be marked as such.

See: #666
This is reflected in the polyfill but not yet in the spec. It's also not
complete, since it will change anyway due to #522, but it's enough to make
the spec changes for calendar.fields make sense.

See: #666
@ptomato ptomato force-pushed the 666-calendar-fields branch from 113fa29 to 9dcf449 Compare October 22, 2020 21:59
@ptomato ptomato requested a review from Ms2ger October 22, 2020 22:00
The Calendar.fields method is called whenever Temporal needs to determine
if a calendar object requires extra fields to uniquely identify its date.

Closes: #666
@ptomato ptomato force-pushed the 666-calendar-fields branch from 9dcf449 to 292b17f Compare October 22, 2020 23:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fields operation on calendar
4 participants