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

"Which Temporal type do I use" flowchart #655

Closed
ptomato opened this issue Jun 9, 2020 · 9 comments
Closed

"Which Temporal type do I use" flowchart #655

ptomato opened this issue Jun 9, 2020 · 9 comments
Milestone

Comments

@ptomato
Copy link
Collaborator

ptomato commented Jun 9, 2020

It would be useful to have a "Which Temporal type do I use" flowchart in the documentation, similar to "Which STL container do I use"

@ptomato ptomato added documentation Additions to documentation nice to have labels Jun 9, 2020
@ptomato ptomato changed the title " "Which Temporal type do I use" flowchart Jun 9, 2020
@justingrant
Copy link
Collaborator

Not exactly a flowchart, but I built a visual "which Temporal type to use when parsing from a string?" graphic for #716 (comment). I built it in PowerPoint because I was too lazy to make it into an SVG, but it's probably pretty easy to turn into an SVG for easier inclusion in the docs if an image is not good enough.

A more complete version of this image would include a bracket for TimeZone (once we agree about whether an offset is a time zone or not!) and Calendar. And perhaps Duration and Now shown sitting off to the side, lonely and disconnected like Alaska and Hawaii in US maps. ;-)

Temporal Type to ISO Strings.pptx

image

@ljharb
Copy link
Member

ljharb commented Aug 26, 2020

@justingrant this is amazing, and I would strongly encourage this diagram to actually be part of the spec text itself (there's a few existing diagrams).

(if so, please include editable source so future changes can be easily made)

@jasonwilliams
Copy link
Member

jasonwilliams commented Aug 26, 2020

I agree with @ljharb including this would be useful. However i think this may serve a different purpose to what a flow chart may serve. I can see this being useful for mentally mapping an ISO string back to Temporal types (especially for those who aren't used to ISO strings)

As well as the useful breaking-down of a full ISO date, I would still like to see a flowchart. A flowchart can serve a great purpose for users who don't know where to begin and need a starting point.

@acutmore
Copy link

acutmore commented Nov 8, 2020

The RxJs docs used to have a nice flow chart mechanism with their docs. I believe it was generated from these pages:
https://github.com/Reactive-Extensions/RxJS/blob/master/doc/gettingstarted/which-static.md
https://github.com/Reactive-Extensions/RxJS/blob/master/doc/gettingstarted/which-instance.md
Can definitely see a similar thing being useful for Temporal.

Tangentially related I made this today:

temporal-navigation

I'm thinking of doing similar ones for other aspects of Temporal.

@justingrant
Copy link
Collaborator

Nice diagram! Note that ISO strings can be parsed into any Temporal type, not only ZonedDateTime and Instant.

Also, take a look at https://tc39.es/proposal-temporal/docs/#object-relationship which is somewhat similar (albeit less detailed and with boxes in different places) than your diagram above.

@acutmore
Copy link

acutmore commented Nov 9, 2020

Nice diagram! Note that ISO strings can be parsed into any Temporal type, not only ZonedDateTime and Instant.

Thanks @justingrant 😀 I did start adding links from string to all the other Temporal types but ran out of room 😂, but you're 100% right that it makes it look like that is the only type that can be created from the ISO string.

I've updated the diagram to with a catch all *.from(str) similar to the *.toString(options*) link

@justingrant
Copy link
Collaborator

@justingrant this is amazing, and I would strongly encourage this diagram to actually be part of the spec text itself (there's a few existing diagrams).

(if so, please include editable source so future changes can be easily made)

@ljharb A later version of this chart was just merged into the docs in #1168. I ported the chart from PowerPoint to cleaned-up SVG to make it easy to embed anywhere and to edit later.

I'd be happy to put it into the spec, but where would you recommend to put it?

@ljharb
Copy link
Member

ljharb commented Nov 12, 2020

I'm not sure :-) when the spec is ready for review, I'll certainly keep an eye open for a good spot, but for now, probably just pick one.

@ptomato
Copy link
Collaborator Author

ptomato commented Jan 2, 2023

Moved to the developer-education task list: js-temporal/temporal-developer-education#3

@ptomato ptomato closed this as completed Jan 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants