-
Notifications
You must be signed in to change notification settings - Fork 156
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
size-suggestion: Consider merging Temporal.Now.xISO()
and Temporal.Now.x()
#2846
Comments
My origional suggestion could be found in https://docs.google.com/document/d/16Rd43XB8z6iLC2c9AfF--unDFg_t476tI1PFe7PbbcM/ |
I'm quite positive about this one. (This was the design I preferred in the first place, during those discussions many years ago.) |
It took a very long time for the champions to agree on these methods. They successfully achieved the goal of making it explicit where a calendar is introduced when creating or converting between Temporal types. I have no opinion on whether to remove the Going a step further and making the calendar argument optional in one way or another would reopen a can of worms and I can't get behind that without further research. |
Adding a required Let's discuss further among the champions. |
Have we considered leaving only one method in place, |
Meeting 2024-05-23: @sffc will sync with his team about the proposal below. If they're OK with it, then at the upcoming June 2024 TC39 plenary meeting, we'll propose the following: To save 4 methods, to simplify Temporal DX, and to avoid bugs we've already seen from having pairs of calendar-required vs. calendar-optional methods, we'll remove the following APIs:
Use cases for these methods will be handled using a two-method chain: the first call to // current
Temporal.Now.zonedDateTime('chinese');
instant.toZonedDateTime({ timeZone: 'Asia/Tokyo', calendar: 'japanese' });
// proposed
Temporal.Now.zonedDateTimeISO().withCalendar('chinese')
instant.toZonedDateTimeISO('Asia/Tokyo').withCalendar('japanese'); The
In addition, if his team is OK with the changes above, @sffc will also discuss with his colleagues whether it'd be OK to make an additional change: to remove the If we removed the ISO suffixes, it'd make these methods more ergonomic and less error prone, and it'd also fix the oddity of If renaming is not OK-ed, we'll simply propose the function removals. |
Just checking, but how do you feel about moving the |
Worth discussing in its own issue, I think. A risk of |
For IDE autocomplete, the suffix is much better because it puts the important parts up-front, so you can type
Agreed, I'll create a new issue for this. |
|
Removal of Instant.p.toZonedDateTime, Now.zonedDateTime, Now.plainDateTime, and Now.plainDate can be seen here. |
I personally think the term "iso" is not very helpful because it is ambiguous in the computer world. For example:
When new engineer find a function name with a Iso stem, depending on what s/he learn before, s/he may assume any of above are related. |
Don't forget ISO/IEC 22275:2018, the ECMAScript standard! Maybe it's just referring to ISO JavaScript, in case you forgot which language you were programming in. |
I would prefer |
so... what is the reason that we need to have a suffix? |
I'd guess most JavaScript programmers are familiar with Date.prototype.toISOString, so "ISO" in the context of date-time functions should be clear to most. |
This is 100% correct. When most JS developers hear "ISO" they'll think of the string format:
I think the problem is that developers only know "ISO" as a format, not a calendar. Most developers will NOT know that there is an "ISO 8601 calendar" that is almost the same as Gregorian except for eras and week numbering. So I don't think that JS devs' previous experience with Date.prototype.toISOString will be helpful in teaching them that an "ISO" or "ISO8601" suffix has anything to do with calendars. It may just as likely confuse them, i.e. "what does a calendar have to do with a string format?" I think we'll be much more successful evangelizing to developers that if they care about calendars, they should call And I question whether the ISO suffix will be successful. I'd recommend removing it, so we'd end up with usage patterns like this: zdt1 = Temporal.Now.zonedDateTime()
zdt2 = Temporal.Now.zonedDateTime().withCalendar('chinese') |
I chatted with sffc offline and now I understand why he think it is important to have the suffix- since there are two possible ways if there are no explicit arguement to put in-
My understanding is the following two lines should always be true
|
In the future, adding |
Meeting 2024-05-30: Feedback from Shane's team was that it's OK to remove the non- |
We could combine three
Temporal.Now
method pairsplainDate
/plainDateISO
,plainDateTime
/plainDateTimeISO
, andzonedDateTime
/zonedDateTimeISO
. We'd also want to remove the ISO suffix fromTemporal.Now.plainTimeISO
.To merge these methods without a huge step backwards in ergonomics, each method would need to have its
calendarId
parameter be optional with theiso8601
calendar as the default. (This is the same behavior as infrom
methods.)This issue is adapted from suggestions made by @FrankYFTang to help reduce the size of Temporal to address concerns from implementers (especially Android and Apple Watch) that Temporal's install size and/or in-memory size is too large.
An even-more-radical simplification could be to make all
Temporal.Now
methods parameterless, and instead rely onwithCalendar()
on the result to use a non-ISO calendar, and to rely on other conversion methods to change the time zone of the resulting object. (Choosing a time zone fromTemporal.Now
is rare.)To reduce one more method, we could also consider merging or changing
Temporal.Instant
's prototype methodstoZonedDateTimeISO
andtoZonedDateTime
, but that merger would be a bit more challenging because:Temporal.Instant
to aTemporal.ZonedDateTime
by adding a time zone is one of the most common operations in Temporal, and it's important not to make its ergonomics worse.toZonedDateTime
functions on PlainDate and PlainDateTime, so consistency across them is also important.Some historical context: (copied from tc39/ecma402#891 (comment))
The text was updated successfully, but these errors were encountered: