Try use more system locale

Hopefully locale doesn't change half way
pull/182/head
Lim Chee Aun 2023-07-08 13:43:25 +08:00
rodzic 41fa08536e
commit b02cae4967
2 zmienionych plików z 5 dodań i 2 usunięć

Wyświetl plik

@ -1,9 +1,10 @@
const { locale } = new Intl.DateTimeFormat().resolvedOptions();
function niceDateTime(date, { hideTime, formatOpts } = {}) {
if (!(date instanceof Date)) {
date = new Date(date);
}
const currentYear = new Date().getFullYear();
const locale = new Intl.DateTimeFormat().resolvedOptions().locale;
const dateText = Intl.DateTimeFormat(locale, {
// Show year if not current year
year: date.getFullYear() === currentYear ? undefined : 'numeric',

Wyświetl plik

@ -1,5 +1,7 @@
const { locale } = Intl.NumberFormat().resolvedOptions();
export default function shortenNumber(num) {
return Intl.NumberFormat('en-US', {
return Intl.NumberFormat(locale, {
notation: 'compact',
}).format(num);
}