-
Notifications
You must be signed in to change notification settings - Fork 56
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
Temporal proposal #311
Comments
Stream of consciousness before we take this up properly:
|
What is wrong with Gregorian-only for non-user-facing date handling? |
I was wondering the same. |
I have a PR out for review at WebIDL to add BigInt support, but it's waiting for use cases to be articulated. I'm not sure if we'd need BigInt in WebIDL just to support Instant being used in DOM, though.
Could you say more about use cases for a time delta representation? |
Example would be something like this:
(Although this proposal doesn't include a operator overloaded syntax, this is just an example of a use case.) |
Re: time-delta This is actually a fair bit more complicated than that. For one thing, the delta depends on TimeZones which may not be available. So the approach we have chosen for temporal is to be explicit. So for
If you assume |
Re: DOMHighResTimeStamp/DOMTimeStamp Both of these are defined as floating point values representing milliseconds. That in turn means that while the resolution may be sufficient, the precision may be off. Again we have opted to be more explicit.
Being explicit and using Using
allows for interoperation. |
Because the Gregorian calendar makes a lot of assumptions that isn't really the case. Think along the lines of days that don't start at midnight. So if you want to do date-calculations, then you have to work in the same calendar as is user-facing, or you are almost guaranteed to get sporadically wrong results. |
That question was in the context of HTML doing something bad, but HTML doesn't do date calculations that I know about. |
Our I previously hadn't looked much at
|
One thing that would be extremely useful to web apps would be the ability to access the list of IANA time zone names known by the system, possibly as a map with their offsets. |
@plinss since the Olson database changes over time, I'm concerned about the fingerprinting implications of exposing the client's known time zone names. |
About the privacy concern, I believe this information can already be inferred through the Intl.DateTimeFormat API. |
About @plinss 's feature request, there was an alternative proposal writeup which would just expose the tz database, rather than including it in a higher level API, and some web authors expressed support for this alternative. We had some discussion in TC39 about a lower-level API in TC39, but decided it was important to unify and provide good tools for high-level usage as well. |
Took up at Tokyo f2f. Thanks for the responses so far. As noted by @plinss above, we would really like to see the named time zones provided (if not in this proposal, than in some other venue) to complete the web developer experience of understanding the offsets. |
Thanks for the feedback. I'll investigate whether we can provide this in the TC39 Temporal proposal. |
The Temporal champion group has made several revisions to the proposal based on feedback it's received from the TAG and others. The changes to the proposal are now complete, and now is a good time for final feedback on the documentation and specification before Stage 3 and implementation in browsers. Some specific comments about the current proposal with respect to the TAG's past feedback:
Specifically, about integration with WebIDL and other web specs:
As an introduction to the current API shape of Temporal, see this presentation which walks through the basic types and operations. Our plan is to integrate this sort of discussion into the Temporal documentation. |
This patch lets Temporal objects be serialized, both in storage and with postMessage, if they use built-in calendars and timezones. This is the only expected integration of Temporal with HTML/DOM expected initially; see earlier discussion in w3ctag/design-reviews#311 The current draft just includes Temporal.PlainDate, and it will be extended to all of the Temporal types after initial review. This patch should not be landed until (at least) Temporal reaches Stage 3.
@cynthia, @kenchris, and I discussed this in our VF2F today. Since there is no explainer but only documentation & the spec, we missed a list of user needs, which would facilitate review. However, based on the documentation, we are concerned that while powerful, this API is very difficult to use for simpler use cases (see principle of Least Power). One source of cognitive overhead is the deep hierarchy of objects, the distinction between which is based on what information is available (e.g. day+month vs day+month+year vs month+year or types without a timezone and types with a timezone). Not only does this mean that when objects are constructed based on incremental user input, the developer will need to continuously convert between types, but it also forces the API to promote factory methods for object creation which need to be learned separately, as opposed to constructors. We were wondering about the reasoning behind this decision, compared to a single object, with some of its information While reviewing, we also spotted a typo in your documentation: in the example here the unit is probably |
We discussed what to do about this in today's call - while we have some concerns (as noted above) if the feedback is not actionable we don't think we should block this work. Hopefully there will be some libraries that make this API easier to use for average users. Thanks for bringing this to your attention! (As for the pattern discussion, we should probably make that a separate discussion on design-principles.) |
Hi TAG! First of all I apologize for not responding sooner. Through my own fault I wasn't subscribed to this thread until two weeks ago, and at that point all my time was taken up with preparing for the TC39 plenary, and later recovering from it. Thanks for taking the time to review the proposal. I have some responses below to Lea's and Sangwhan's messages.
I've been looking over the requirements for an explainer and while it's true that we don't have a document that follows this format, we did intend our documentation and cookbook to fulfill roughly the same function, of describing the rationale for the proposal, the user needs motivating it, and showing samples of how users would solve problems using it. I'd be interested in hearing more about what was missing from these resources which would have helped with your review, so we can improve this going forward.
I can give the rationale for having multiple classes in the proposal. (There is more background in tc39/proposal-temporal#927 and tc39/proposal-temporal#51 if you want to read more about it.) Having strong types is a design decision that was made to avoid bugs that might occur if developers had only one class to work with and had to fill in arbitrary values for missing data, and then decipher what that meant. For example, "00:00:00" might be a common interpretation of null hour/minute/second fields, but until recently Brazil had their DST transitions at midnight, so for one day every year, that time would not exist, leading to unexpected and hard-to-track-down bugs. The "correct" workaround, to use noon rather than midnight as the missing-time value, is not well-known to most web developers. In fact the question about HTMLTimeElement integration from the previous review that the TAG did a couple of years ago was part of the motivation for adding the PlainYearMonth and PlainMonthDay types. I do want to acknowledge that this is a matter of taste. While we've gotten some feedback that many developers seem to understand and agree with the idea of representing your data more precisely with strong types, certainly plenty of developers would be happier with a single, more generic class as you suggested. If they wanted to, these developers could use Temporal.ZonedDateTime as an "everything" class, but in the documentation and cookbook we don't currently encourage it to be used that way, since it could lead to the type of bugs mentioned above. In any case, the decision to have multiple classes is foundational to the proposal and I don't believe it would be possible to change it at this point, unless we started over with a different proposal altogether. But I hope that this response helps mitigate the concerns you mentioned, certainly legitimate ones, about cognitive overhead.
I'm hopeful that using Temporal.ZonedDateTime for everything would be at least as good of a solution as relying on a wrapper library. That said, if someone does make some sort of a "simplified Temporal" library, I wouldn't be overly sad, as Temporal gives better tools for doing this than the Date object ever did, and avoids the need for that wrapper library to contain a copy of the time zone database which users need to download over and over again.
I'm not certain of the link that you mentioned between multiple classes and factory methods; that is also a design decision that's a matter of taste, but I do think it's a separate one from the decision to have multiple classes. Speaking personally, I also prefer constructors above factory methods, but it's my understanding that that's not a universal opinion, and I think the current split between low-level constructors related directly to the data model, and high-level factory methods accepting more kinds of input, is a good compromise. We did have an earlier thread with Lea about this.
I think this has been fixed in the meantime, thanks! |
This patch lets Temporal objects be serialized, both in storage and with postMessage, if they use built-in calendars and timezones. This is the only expected integration of Temporal with HTML/DOM expected initially; see earlier discussion in w3ctag/design-reviews#311 The current draft just includes Temporal.PlainDate, and it will be extended to all of the Temporal types after initial review. This patch should not be landed until (at least) Temporal reaches Stage 3.
This patch lets Temporal objects be serialized, both in storage and with postMessage, if they use built-in calendars and timezones. This is the only expected integration of Temporal with HTML/DOM expected initially; see earlier discussion in w3ctag/design-reviews#311 The current draft just includes Temporal.PlainDate, and it will be extended to all of the Temporal types after initial review. This patch should not be landed until (at least) Temporal reaches Stage 3.
This patch lets Temporal objects be serialized, both in storage and with postMessage, if they use built-in calendars and timezones. This is the only expected integration of Temporal with HTML/DOM expected initially; see earlier discussion in w3ctag/design-reviews#311 Co-authored-by: Domenic Denicola <[email protected]> Co-authored-by: Ms2ger <[email protected]>
This patch lets Temporal objects be serialized, both in storage and with postMessage, if they use built-in calendars and timezones. This is the only expected integration of Temporal with HTML/DOM expected initially; see earlier discussion in w3ctag/design-reviews#311 Co-authored-by: Domenic Denicola <[email protected]> Co-authored-by: Ms2ger <[email protected]>
Bonjour TAG,
I'm requesting a TAG review of:
Further details (optional):
Date.now()
-like functionality, which this proposal currently omits.You should also know that...
It would be helpful to get feedback on which date/time units are useful/needed for web APIs (e.g., this proposal omits a duration type). The date/time types here may enable changes in the TAG's API Design Principles, c.f., w3ctag/design-principles#101
We'd prefer the TAG provide feedback as (please select one):
The text was updated successfully, but these errors were encountered: