-
Notifications
You must be signed in to change notification settings - Fork 152
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
Rename conversion methods to toFoo #705
Conversation
Codecov Report
@@ Coverage Diff @@
## main #705 +/- ##
=======================================
Coverage 92.33% 92.33%
=======================================
Files 17 17
Lines 4733 4733
Branches 743 743
=======================================
Hits 4370 4370
Misses 360 360
Partials 3 3
Continue to review full report at Codecov.
|
This looks fine, is it marked draft because you still intend to rename other methods as well? |
@ptomato precisely. |
Made all expected changes, rebased and now this is ready for review. I'd like to note that it introduces a new ambiguity (now three methods, not two) between |
Changes look good, but I was under the impression that we were also going to rename all (copying from #574 (comment))
|
@justingrant oops, I totally forgot about those. Will do them today. |
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.
I didn't pay too much attention to the test262 part, but looks good, pending the other renames that you mentioned.
I would like to consider alternatives for YearMonth.toDate() and MonthDay.toDate() because I seriously think toDate(2020)
and toDate(1)
look confusing.
@@ -1,6 +1,6 @@ | |||
const birthday = Temporal.MonthDay.from('12-15'); | |||
|
|||
const birthdayIn2030 = birthday.withYear(2030); | |||
const birthdayIn2030 = birthday.toDate(2030); |
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.
Hmm, here is an example of where I really prefer the old names ... toDate(year)
as below is OK, but toDate(2030)
with a number literal is more mystifying to me. I know I was in the minority on that viewpoint so I definitely don't want to push for bringing the old names back; but maybe there is a third way? How about calling it toDateIn()? e.g. toDateIn(2030)
, toDateIn({ era: 'reiwa', year: 12 })
@@ -6,7 +6,7 @@ | |||
*/ | |||
function getFirstTuesday(queriedMonth) { | |||
// We first need to convert to a date | |||
const firstOfMonth = queriedMonth.withDay(1); | |||
const firstOfMonth = queriedMonth.toDate(1); |
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.
Same here, maybe toDateOn(1)
? (although that reads to me as less obvious than toDateIn(2030)
)
docs/cookbook/meetingPlanner.js
Outdated
.withTime(Temporal.Time.from('00:00')) // midnight | ||
.inTimeZone(here); | ||
.toDateTime(Temporal.Time.from('00:00')) // midnight | ||
.toDateTime(here); |
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.
I think this should be toAbsolute()
?
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.
Oops. Will fix.
@ptomato that rebase was a little sad, with 29 commits and all, but it's finally done! Please take another look? |
This looks good, but I would really like to consider |
One pattern we could consider would be |
@ptomato I have no strong preferences here, I think we're much better now in that:
Feel free to make any suggestion for the methods that seem confusing to you. @justingrant's suggestion of separating
makes sense. However, as he points it, it tends to get too verbose. Besides, I'm atleast slightly uncomfortable reusing |
Rename Temporal.DateTime.prototype.inTimeZone to Temporal.DateTime.prototype.toAbsolute and Temporal.Absolute.prototype.inTimezone to Temporal.Absolute.prototype.toDtoDateTime for the sake of clarity.
@ptomato - Given the scope of this PR and the challenge of rebasing it each time, would it make sense to merge as-is and then do a smaller follow-up PR to address naming for the two methods that you're concerned about? |
@justingrant @ptomato squashed and rebased 😇 |
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.
OK.
Fixes: #574.
/cc @ptomato @justingrant