`Temporal` upcoming feature
Can anyone recommend some good resources for learning about the new
Temporal
API that's in proposal?
I've been reading the official docs but I find the examples and explanations a bit lacking and inexhaustive.
If there's a YouTube video using one of the polyfills that would be ideal, but I'm yet to find something that goes beyond what the docs show.3 Replies
Yea, temporal. I heard of it and it looks very promising.
I didn't watch it yet, but saw this video passing my in my timeline. Maybe it is something https://www.youtube.com/watch?v=oOK3UzLJ_Cs
Web Dev Simplified
YouTube
Learn Temporal API In 17 Minutes
My Blog: https://blog.webdevsimplified.com
Temporal API Article: https://blog.webdevsimplified.com/2022-02/temporal-date-api
Date in JavaScript suck to work with. They are clunky, have a terrible API, and overall make writing code less fun. Luckily, the Temporal API is being added to JavaScript which solves all the problems I have with dates an...
does it allow for date formating with string templates (like
AAAA-MM-dd
,like in php, python, java, c, sql...) or did they do their thing again?
I saw it worked with "pre built formats" but having more control without needing 50lines of code would be nicedatetime.toLocaleString(locales?: string | array<string>, options?: object) : string
The locales and options arguments are the same as in the constructor to Intl.DateTimeFormat (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat).
- https://tc39.es/proposal-temporal/docs/plaindatetime.html#toLocaleString
This is the same for all the date/time objects in Temporal, so you can do it in a single call, but you have to provide the presentation in a config object rather than a string template. Not as bad as Date
, but not as good as <insert lang here>