One Way to Format, Everywhere
marcelochaman.com · 1,650 words · saved by 1 readers
Centralized formatters for consistency, with cached Intl objects for performance
1export { toDate, toDateNullable, isValidDate }; 2export type { DateInput, DateInputNullable }; 3 4const getDTF = createCachedIntlGetter< 5 Intl.DateTimeFormatOptions, 6 Intl.DateTimeFormat 7>((locale, opts) => new Intl.DateTimeFormat(locale, opts)); 8 9const getRTF = createCachedIntlGetter< 10 Intl.RelativeTimeFormatOptions, 11 Intl.RelativeTimeFormat 12>( 13 (locale, opts) => new Intl.RelativeTimeFormat(locale ?? DEFAULT_LOCALE, opts), 14); 15 16type DurationFormatOptions = { 17 style?: 'long' | 'short' | 'narrow' | 'digital'; 18}; 19interface DurationFormatter { 20…
saved by
related reading
- GitHub - wanasit/chrono: A natural language date parser in Javascriptgithub.com
- Dates and Times | SheetJS Community Editiondocs.sheetjs.com
- OpenAI Platformplatform.openai.com
- Home | Santa Fe Institutesantafe.edu
- Proglogic - All Toolsproglogic.com
- 9.9. 时间/日期函数和操作符postgres.cn
- Miniproject #1 2021 | Kagglekaggle.com
- Golang Time Format: Format and Parse Time with Layout Examplesgolinuxcloud.com
- Sentiment Lexicons for 81 Languages | Kagglekaggle.com
- Epoch Converter - Unix Timestamp Converterepochconverter.com
- Mediummedium.easyread.co
- Yet Another Chinese News Dataset | Kagglekaggle.com