-
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
"Which Temporal type do I use" flowchart #655
Comments
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. ;-) |
@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) |
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. |
The RxJs docs used to have a nice flow chart mechanism with their docs. I believe it was generated from these pages: Tangentially related I made this today: I'm thinking of doing similar ones for other aspects of Temporal. |
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. |
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 |
@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? |
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. |
Moved to the developer-education task list: js-temporal/temporal-developer-education#3 |
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"
The text was updated successfully, but these errors were encountered: