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

withYear() object argument #550

Merged
merged 2 commits into from
May 13, 2020
Merged

withYear() object argument #550

merged 2 commits into from
May 13, 2020

Conversation

ptomato
Copy link
Collaborator

@ptomato ptomato commented May 11, 2020

Closes: #490

@ptomato ptomato requested review from Ms2ger, sffc and ryzokuken May 11, 2020 18:11
@codecov
Copy link

codecov bot commented May 11, 2020

Codecov Report

Merging #550 into main will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##             main     #550   +/-   ##
=======================================
  Coverage   97.53%   97.53%           
=======================================
  Files          17       17           
  Lines        4013     4019    +6     
  Branches      596      599    +3     
=======================================
+ Hits         3914     3920    +6     
  Misses         97       97           
  Partials        2        2           
Flag Coverage Δ
#test262 53.60% <100.00%> (+0.08%) ⬆️
#tests 93.09% <100.00%> (+0.03%) ⬆️
Impacted Files Coverage Δ
polyfill/lib/monthday.mjs 98.91% <100.00%> (+0.07%) ⬆️

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 f3253de...cff3a54. Read the comment docs.

Copy link
Member

@ryzokuken ryzokuken left a comment

Choose a reason for hiding this comment

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

LGTM, thanks. Will merge once @sffc approves.

if (typeof item === 'object') {
({ year } = ES.ToRecord(item, [['year']]));
} else {
year = ES.ToInteger(item);
Copy link
Member

Choose a reason for hiding this comment

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

We weren't calling ToInteger before? 😳

The following steps are taken:
</p>
<emu-alg>
1. Let _monthDay_ be the *this* value.
1. Perform ? RequireInternalSlot(_monthDay_, [[InitializedTemporalMonthDay]]).
1. Let _y_ be ? ToInteger(_year_).
Copy link
Member

Choose a reason for hiding this comment

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

Idk why the polyfill wasn't doing this 😅

ptomato added 2 commits May 12, 2020 16:03
This argument is necessary when you have a calendar where the year is
not enough information to convert from MonthDay to Date. e.g.:

    const monthDay = Temporal.MonthDay.from({ month: 4, day: 1, calendar: 'japanese' });
    const date = monthDay.toDate({ year: 18, era: "heisei" });

The existing API should continue to work unchanged, although there is
one behavioural change. An object with valueOf() returning a number will
no longer act as a number argument, because it will instead go down the
object argument code path.

See: #490
@ptomato ptomato force-pushed the 490-withyear-object-argument branch from 6a4f8ff to cff3a54 Compare May 12, 2020 23:03
@ryzokuken
Copy link
Member

Thanks @ptomato for the PR and @sffc for the review. I'll merge this in now.

@ryzokuken ryzokuken merged commit 5021ead into main May 13, 2020
@ryzokuken ryzokuken deleted the 490-withyear-object-argument branch May 13, 2020 05:17
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.

Semantics of type conversion methods with calendars
3 participants