Learn how JavaScript advances DateTime with proposal-temporal

Brian Douglas - Sep 15 '20 - - Dev Community

There comes a time in every developer's life where they need to parse a string representation of a date. I had the pleasure of talking with Maggie Pint about a new feature currently in stage 2 with the tc39 committee, temporals.

Learn how to contribute to the next version of JavaScript first issue.

This proposal allows a JavaScript programmer the ability to write code for finding out the current timezone difference between their's and another time zone.

const { Temporal } = require('proposal-temporal')

let londonTz = Temporal.TimeZone.from('Asia/Shanghai');

console.log(now.toString(londonTz));
Enter fullscreen mode Exit fullscreen mode

A complete polyfill can be found here. Feel to test it out today and experiment with the polyfill, but keep in mind it is not production ready yet.

GitHub logo tc39 / proposal-temporal

Provides standard objects and functions for working with dates and times.

Temporal

Provides standard objects and functions for working with dates and times.

Status

This proposal is currently Stage 3 and was reviewed for Stage 3 by Richard Gibson, Bradley Farias, and Daniel Ehrenberg.

This proposal is now in the hands of ECMAScript engine implementers, so the bar for making API changes is extremely high Nonetheless, changes may occur as the result of feedback from implementation in JS engines. Editorial changes to the spec and bug fixes to the spec, tests, and docs are also ongoing, as is customary for Stage 3 proposals. Additional tests and documentation content are also being added during Stage 3.

Champions

I share only one feature from the proposal, I encourage you to read more info in the spec and test it out today in consoles.

Join us live for Open Source Fridays

If you’re looking for a deep dive into contributing to open-source projects like this, join us on Fridays on Twitch. You can find the future schedule on GitHub Virtual Meetup page.

If you missed our previous OSF stream, or want to rewatch, you can find the full video over on our YouTube.

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .