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 ...
For further actions, you may consider blocking this person and/or reporting abuse
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 :)
It’s custom — all open-source in the repo though in the docs directory: github.com/formkit/tempo/tree/main...
Cool, thanks! I'll take a look
Thats the difference to dayjs?
github.com/iamkun/dayjs
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.
dayjs with a locale imported is 6kb for me in my current configuration
https://bundlejs.com/?q=dayjs%2Cdayjs%2Flocale%2Fde%2Cdayjs%2Fplugin%2Fduration%2Cdayjs%2Fplugin%2FquarterOfYear%2Cdayjs%2Fplugin%2FrelativeTime%2Cdayjs%2Fplugin%2FweekOfYear&treeshake=%5B*%5D%2C%5B*%5D%2C%5B*%5D%2C%5B*%5D%2C%5B*%5D%2C%5B*%5D&share=CYQwngVgzgdApgDwC5wHbABQCc4BsRICWAbnACqEC2cAlAAQD0DdAFkkgA5QBcToYMaDAD2WAOYNgwgMZQGaBh1wBXMYVQMc%2BIqQC0RagCh%2BQ3DJC44GAETA41%2Bk1bsuvSeEGxREqbPkbCAEYADg1pFhBUNSjdM2kLOGNwIUQUdAwAEWUsAkJhVEdmNk4ePg8hb0kZOQUlVXVJbNz8pMhYVLRMAHc4OABrAHkAMwBNOBAsQucSt35PEXEqv1qVaIYe-t1hId0wcaxWlOROjABHZQmULGGxiani1zKBCsXfGo06tfPLuCwtnb2E0MhkQHFESDodiGIGUuAhJigQA
What kind of "locale aware formatting options" do you mean?
If I use
dayjs().format("MMMM YYYY")
it works just fine for me with the configured localeBut
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
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)
All of tempo with no tree shaking at all is 5.2Kb gzipped.
This is good!
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?
"𝗙𝗢𝗟𝗟𝗢𝗪 𝗕𝗔𝗖𝗞 𝗙𝗢𝗥 𝗠𝗢𝗥𝗘 𝗜𝗡𝗦𝗜𝗚𝗛𝗧𝗙𝗨𝗟 𝗗𝗜𝗦𝗖𝗨𝗦𝗦𝗜𝗢𝗡"