loading...
Play Button Pause Button
GitHub

Learn how JavaScript advances DateTime with proposal-temporal

bdougieyo profile image Brian Douglas Updated on ・1 min read

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));

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.

NOTE: The Polyfill, specification text and documentation are under continuing development and should be understood to be unstable.

Champions

Status

This proposal is currently stage 2.

Stage 3 Reviewers:

  • Richard Gibson
  • Bradley Farias
  • Daniel Ehrenberg

Overview / Motivation

Date has been a long-standing pain point in ECMAScript This proposes Temporal, a global Object that acts as a top-level namespace (like Math), that brings a modern date/time API to the ECMAScript language For a detailed breakdown of motivations, see Fixing JavaScript Date

Principles:

  • All Temporal objects are immutable.
  • Date values can…

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.

Posted on by:

bdougieyo profile

Brian Douglas

@bdougieyo

Brian is a developer advocate at GitHub, which means he likes chatting with developers about developer things and sometimes writes code.

Discussion

pic
Editor guide
 

nice article. check out moment.js and its sister utc transform library. great stuff :) thank you.