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

ZonedDateTime.toLocaleString() and last cookbook example #1153

Merged
merged 6 commits into from
Nov 10, 2020
Merged

Conversation

ptomato
Copy link
Collaborator

@ptomato ptomato commented Nov 6, 2020

See: #569

@codecov
Copy link

codecov bot commented Nov 6, 2020

Codecov Report

Merging #1153 (7015dcb) into main (5930868) will decrease coverage by 2.92%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1153      +/-   ##
==========================================
- Coverage   93.55%   90.63%   -2.93%     
==========================================
  Files          19       17       -2     
  Lines        7961     8797     +836     
  Branches     1264     1245      -19     
==========================================
+ Hits         7448     7973     +525     
- Misses        506      813     +307     
- Partials        7       11       +4     
Flag Coverage Δ
test262 ?
tests 90.63% <ø> (+1.19%) ⬆️

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

Impacted Files Coverage Δ
polyfill/lib/legacydate.mjs
polyfill/lib/shim.mjs
polyfill/lib/slots.mjs
polyfill/lib/intrinsicclass.mjs
lib/calendar.mjs 77.59% <0.00%> (ø)
lib/temporal.mjs 100.00% <0.00%> (ø)
lib/plainmonthday.mjs 83.79% <0.00%> (ø)
lib/intl.mjs 99.74% <0.00%> (ø)
lib/regex.mjs 100.00% <0.00%> (ø)
lib/intrinsicclass.mjs 56.81% <0.00%> (ø)
... and 11 more

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 116256a...06ea4f4. Read the comment docs.

polyfill/lib/intl.mjs Outdated Show resolved Hide resolved
spec/intl.html Outdated Show resolved Hide resolved
The ZonedDateTime's time zone wins over the system's default time zone.
If you explicitly give a time zone in the formatter options, and you try
to format a ZonedDateTime with a time zone which is different from the
explicitly given time zone, then toLocaleString() will throw an exception.

formatRange() and formatRangeToParts() require ZonedDateTimes with the
same time zone.

See: #569
Now that ZonedDateTime.toLocaleString() works, we can fix this example. It
becomes much simpler using ZonedDateTime.

See: #569
In DateTimeFormat.format, we need to call toString() to get the calendar
ID only once, instead of several times.
Copy link
Collaborator

@justingrant justingrant left a comment

Choose a reason for hiding this comment

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

Looks good. I admittedly don't know much about the innards of toLocaleString so I focused my review on the cookbook sample and the high-level expectations like throwing if zones are mismatched.


// Show the date in midnight cells
let formatOptions;
if (dt.hour === 0) {
if (columnTime.hour === 0) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think you probably want to compare columnTime to .startOfDay here, not zero, if you want to handle cases where DST skips an hour starting at midnight.

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's a good point, it does handle other skipped and repeated times gracefully, so it should here as well.

@Ms2ger Ms2ger merged commit db24ae7 into main Nov 10, 2020
@Ms2ger Ms2ger deleted the zoneddatetime-8 branch November 10, 2020 10:02
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.

3 participants