DEV Community

Cover image for Introducing Tempo • A new date library for JavaScript (and TypeScript).

Introducing Tempo • A new date library for JavaScript (and TypeScript).

Justin Schroeder on February 14, 2024

TLDR; Checkout the Tempo docs. Working with dates and time is one of JavaScript’s weakest points. The native Date object is, under the hood, just ...
Collapse
 
danbars profile image
Dan Bar-Shalom

off-topic: how did you build the interactive code demo in the docs?
Is this custom made using monaco and eval, or did you use some product like jsbin?
It has a very clean look, and I couldn't find anything similar.
If it's custom and you want to share a gist with the code it will be highly appreciated :)

Collapse
 
andrewboyd profile image
Andrew Boyd

It’s custom — all open-source in the repo though in the docs directory: github.com/formkit/tempo/tree/main...

Collapse
 
danbars profile image
Dan Bar-Shalom

Cool, thanks! I'll take a look

Collapse
 
adaptive-shield-matrix profile image
Adaptive Shield Matrix

Thats the difference to dayjs?
github.com/iamkun/dayjs

  • dayjs has same or more formatting/parsing/i18n capabilities
  • while being only 2kb in size
Collapse
 
justinschroeder profile image
Justin Schroeder

dayjs is great, but has no locale aware formatting options or parsing options and anything like timezone support is not 2kb as it requires additional plugins.

Collapse
 
 
andrewboyd profile image
Andrew Boyd • Edited

But MMMM YYYYY may not be the correct formatting for a user’s locale. Sure you can force a format, but you dont magically get the correct format like you would with Tempo.

Have you read the docs yet? They’re pretty short and to the point:

tempo.formkit.com/#format-styles

Collapse
 
dakujem profile image
Andrej Rypo • Edited

What is the size of Tempo? (gzipped)

(EDIT: I mean the full version size, I understand that care has been taken to enable tree shaking and minimizet the actual real world size)

Collapse
 
justinschroeder profile image
Justin Schroeder

All of tempo with no tree shaking at all is 5.2Kb gzipped.

Thread Thread
 
dakujem profile image
Andrej Rypo

This is good!

Collapse
 
aditya_raj_1010 profile image
A.R

The introduction of Tempo, a new date library for JavaScript and TypeScript, brings attention to its unique features and aims to address shortcomings in existing libraries. One standout feature is its utilization of the Intl.DateTimeFormat API for styles, allowing both formatting and parsing in a locale-aware manner. Could you elaborate on how Tempo's approach to handling timezones without the need for additional plugins sets it apart? Additionally, the avoidance of the builder pattern and minimal reliance on plugins are highlighted as strengths. How does Tempo achieve a small core size while maintaining robust functionality, and what benefits does this bring to developers in terms of project size and simplicity? Lastly, the documentation and interactive examples are emphasized as user-friendly. How does Tempo's documentation enhance the developer experience, and what interactive features does it offer to aid developers in testing use cases before implementation?

"𝗙𝗢𝗟𝗟𝗢𝗪 𝗕𝗔𝗖𝗞 𝗙𝗢𝗥 𝗠𝗢𝗥𝗘 𝗜𝗡𝗦𝗜𝗚𝗛𝗧𝗙𝗨𝗟 𝗗𝗜𝗦𝗖𝗨𝗦𝗦𝗜𝗢𝗡"