Temporal: Modern Dates and Times in JavaScript

This talk is scheduled for Nov 21, 20:30
The recording will be published after editing. Multipass and Full ticket holders have early access.
Rate this content
Bookmark

Ever been fooled by one of the many pitfalls of the JS Date object? Do you bundle time zone data? Then check out Temporal! Temporal is a TC39 proposal currently being implemented in JS engines, that brings better date and time handling, and time zone awareness, to JS. This talk is a tour of what you need to know about Temporal, walking through one simple, one medium, and one complicated task each solved with Temporal.

This talk has been presented at JSNation US 2024, check out the latest edition of this JavaScript Conference.

FAQ

The Temporal proposal adds modern date and time handling to JavaScript, providing a built-in library for dates and times similar to those in other programming languages.

Temporal aims to address the deficiencies of the existing Date object in JavaScript, such as unwieldy APIs and mutability issues, by providing a more robust and strongly typed system for date and time management.

Temporal provides a strongly typed and immutable approach to date and time management, with support for non-Gregorian calendars and better integration with JavaScript's internationalization facilities.

Temporal introduces several types including Instant, PlainDate, PlainTime, PlainYearMonth, PlainMonthDay, ZonedDateTime, and Duration, each serving different purposes in date and time representation.

Temporal introduces the ZonedDateTime type, which accounts for time zones and daylight saving time changes, providing accurate representation of exact moments in time with time zone rules.

The Instant type represents an exact time point on the timeline with nanosecond precision, without any calendar or time zone information.

Temporal objects are immutable to prevent unwanted modifications by external code, enhancing reliability and predictability in date and time operations.

Yes, Temporal is designed to support non-Gregorian calendars, allowing developers to accurately handle dates in various cultural and regional contexts.

Temporal provides arithmetic methods such as add, subtract, since, and until, allowing precise duration calculations and adjustments across different types of date and time representations.

Developers can explore the Temporal API through its documentation, and once it graduates, it will be available on MDN alongside other JavaScript built-ins.

 Philip Chimento
Philip Chimento
21 Nov, 2024
Video transcription, chapters and summary will be available after the recording is published.

Check out more articles and videos

We constantly think of articles and videos that might spark Git people interest / skill us up or help building a stellar career

Future Features of JS?!
JSNation 2022JSNation 2022
28 min
Future Features of JS?!
Top Content
Welcome to the future features of JavaScript, including proposals for array operations, throw expressions, records and TPUs, pipeline operators, and more. The talk covers the introduction of type assertions for imported files, non-mutating array operations, and the simplification of error handling. It also explores the concept of immutability with records and TPUs, and the use of the pipeline operator to simplify code. Other proposals include Map.implace, IteratorHelper, slice notation, type annotations, Array UNIQBY, number ranges, and the Function 1 proposal.
ES?.next()
JSNation Live 2021JSNation Live 2021
31 min
ES?.next()
The Talk discusses various proposals for the next version of ECMAScript (ES Next) and the TC39 process. It covers features such as binding syntax, shorthand property assignments, pattern matching, async match, operator overloading, and more. These proposals aim to simplify code, make it more readable, and introduce new functionalities. The Talk also addresses questions about the committee's decision-making process and the experience of being part of the TC39 committee.
ESNext: Proposals To Look Forward To
JSNation Live 2020JSNation Live 2020
9 min
ESNext: Proposals To Look Forward To
ES Next proposal stages include straw person, proposal, draft, candidate, and finished. Optional chaining and null coalescing operators are solutions for handling undefined and null values. Logical assignment and null coalescing operators are seeking advancement to stage four. Decimal type is introduced to address floating point math issues. Cancellation API and abort control are solutions for canceling promise execution. Pattern matching allows matching the shape of a vector and performing actions based on it.