mirror of
https://github.com/cheeaun/phanpy.git
synced 2025-03-14 12:18:30 +03:00
Try use more system locale
Hopefully locale doesn't change half way
This commit is contained in:
parent
41fa08536e
commit
b02cae4967
2 changed files with 5 additions and 2 deletions
|
@ -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',
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue