2023-07-27 08:31:52 +03:00
|
|
|
/*
|
|
|
|
* SPDX-FileCopyrightText: syuilo and other misskey contributors
|
|
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
*/
|
|
|
|
|
2023-09-19 10:37:43 +03:00
|
|
|
import { lang } from '@/config.js';
|
2023-01-01 10:11:33 +02:00
|
|
|
|
|
|
|
export const versatileLang = (lang ?? 'ja-JP').replace('ja-KS', 'ja-JP');
|
2023-10-28 01:56:24 +03:00
|
|
|
|
|
|
|
let _dateTimeFormat: Intl.DateTimeFormat;
|
|
|
|
try {
|
|
|
|
_dateTimeFormat = new Intl.DateTimeFormat(versatileLang, {
|
|
|
|
year: 'numeric',
|
|
|
|
month: 'numeric',
|
|
|
|
day: 'numeric',
|
|
|
|
hour: 'numeric',
|
|
|
|
minute: 'numeric',
|
|
|
|
second: 'numeric',
|
|
|
|
});
|
|
|
|
} catch (err) {
|
|
|
|
console.warn(err);
|
|
|
|
if (_DEV_) console.log('[Intl] Fallback to en-US');
|
|
|
|
|
|
|
|
// Fallback to en-US
|
|
|
|
_dateTimeFormat = new Intl.DateTimeFormat('en-US', {
|
|
|
|
year: 'numeric',
|
|
|
|
month: 'numeric',
|
|
|
|
day: 'numeric',
|
|
|
|
hour: 'numeric',
|
|
|
|
minute: 'numeric',
|
|
|
|
second: 'numeric',
|
|
|
|
});
|
|
|
|
}
|
|
|
|
export const dateTimeFormat = _dateTimeFormat;
|
|
|
|
|
|
|
|
let _numberFormat: Intl.NumberFormat;
|
|
|
|
try {
|
|
|
|
_numberFormat = new Intl.NumberFormat(versatileLang);
|
|
|
|
} catch (err) {
|
|
|
|
console.warn(err);
|
|
|
|
if (_DEV_) console.log('[Intl] Fallback to en-US');
|
|
|
|
|
|
|
|
// Fallback to en-US
|
|
|
|
_numberFormat = new Intl.NumberFormat('en-US');
|
|
|
|
}
|
|
|
|
export const numberFormat = _numberFormat;
|