tc39 / proposal-temporal

Provides standard objects and functions for working with dates and times.
https://tc39.es/proposal-temporal/docs/
Other
3.3k stars 149 forks source link

What are use cases for DateTime after LocalDateTime lands? (for documentation) #948

Closed justingrant closed 3 years ago

justingrant commented 4 years ago

Once LDT lands, we'll need to explain the difference to users between DateTime and LDT (or whatever their final names end up being). I think a good way to do this in the docs will be to list some example use cases where DateTime is needed and LDT isn't appropriate. Here's an initial draft. What should be added/removed?

Are there other use cases that the list above omits? We're not looking for convoluted cases where DateTime could be used... but rather what are common use cases where DateTime should be used as a best practice and where LDT isn't appropriate due to bugs, ergonomics, etc.?

Also, what are other examples besides the 4:20 4/20 holiday of a date/time event that should be evaluated the same in every time zone? I thought of a lot of holiday examples (e.g. new year's day) but IMHO those are more properly modeled using a Temporal.Date because they always start at the beginning of the day. What are more examples of intraday events that are the same everywhere?

gibson042 commented 4 years ago

Remembrance Day usually includes a two-minute silence at 11:00.

ryzokuken commented 4 years ago

I suppose the discussion could be copied over here from today's notes and this issue be closed?

ptomato commented 4 years ago

@mj1856 mentioned the use case of countries with one time zone and no DST, where DateTime matches the mental model. @pipobscure mentioned that it matches the mental model in other cases as well, when one is planning events for oneself.

justingrant commented 4 years ago

@mj1856 mentioned the use case of countries with one time zone and no DST, where DateTime matches the mental model.

BTW, after thinking more about the single-country/single-timezone/no-DST use case and I think we should NOT recommend DateTime for this use case in the docs. Developers may choose to ignore our guidance and use DateTime anyways--just like they often do with localization advice--but my proposal would be to document a clear standard that recommends that developers who know the place should use LDT, even in cases like India and China.

Why?

Thoughts?

I suppose the discussion could be copied over here from today's notes and this issue be closed?

I'd suggest that we leave it open and close it via a docs PR, perhaps the same PR that resolves #655 via a docs page that maps specific use cases to the right Temporal type for those cases. Until that PR lands, I think this issue could be a helpful honeypot to attract use cases from other commenters.

justingrant commented 3 years ago

I'd suggest that we leave it open and close it via a docs PR, perhaps the same PR that resolves #655 via a docs page that maps specific use cases to the right Temporal type for those cases. Until that PR lands, I think this issue could be a helpful honeypot to attract use cases from other commenters.

I think it's been open long enough to attract use cases, so I PR-ed some brief use cases into the PDT docs in #1344.