use Intl.DateTimeFormat and Intl.NumberFormat instead of toLocaleString (#9444)

This commit is contained in:
tamaina
2023-01-01 17:11:33 +09:00
committed by GitHub
parent 0222165bd9
commit c3a36698e5
14 changed files with 42 additions and 18 deletions

View File

@ -10,7 +10,7 @@
</MkA>
<MkKeyValue class="_formBlock">
<template #key>{{ i18n.ts.registeredDate }}</template>
<template #value>{{ new Date(report.targetUser.createdAt).toLocaleString() }} (<MkTime :time="report.targetUser.createdAt"/>)</template>
<template #value>{{ dateString(report.targetUser.createdAt) }} (<MkTime :time="report.targetUser.createdAt"/>)</template>
</MkKeyValue>
</div>
<div class="detail">
@ -42,6 +42,7 @@ import MkKeyValue from '@/components/MkKeyValue.vue';
import { acct, userPage } from '@/filters/user';
import * as os from '@/os';
import { i18n } from '@/i18n';
import { dateString } from '@/filters/date';
const props = defineProps<{
report: any;

View File

@ -40,6 +40,7 @@ import { defaultStore } from '@/store';
import { useChartTooltip } from '@/scripts/use-chart-tooltip';
import { chartVLine } from '@/scripts/chart-vline';
import { alpha } from '@/scripts/color';
import date from '@/filters/date';
const props = defineProps({
src: {
@ -171,7 +172,7 @@ const render = () => {
chartInstance = new Chart(chartEl.value, {
type: props.bar ? 'bar' : 'line',
data: {
labels: new Array(props.limit).fill(0).map((_, i) => getDate(i).toLocaleString()).slice().reverse(),
labels: new Array(props.limit).fill(0).map((_, i) => date(getDate(i))).slice().reverse(),
datasets: chartData.series.map((x, i) => ({
parsing: false,
label: x.name,

View File

@ -4,7 +4,7 @@
<MkA
v-for="file in items"
:key="file.id"
v-tooltip.mfm="`${file.type}\n${bytes(file.size)}\n${new Date(file.createdAt).toLocaleString()}\nby ${file.user ? '@' + Acct.toString(file.user) : 'system'}`"
v-tooltip.mfm="`${file.type}\n${bytes(file.size)}\n${dateString(file.createdAt)}\nby ${file.user ? '@' + Acct.toString(file.user) : 'system'}`"
:to="`/admin/file/${file.id}`"
class="file _button"
>
@ -39,6 +39,7 @@ import MkDriveFileThumbnail from '@/components/MkDriveFileThumbnail.vue';
import bytes from '@/filters/bytes';
import * as os from '@/os';
import { i18n } from '@/i18n';
import { dateString } from '@/filters/date';
const props = defineProps<{
pagination: any;

View File

@ -45,11 +45,12 @@
<script lang="ts" setup>
import { defineAsyncComponent, onMounted, onUnmounted } from 'vue';
import { url as local, lang } from '@/config';
import { url as local } from '@/config';
import { i18n } from '@/i18n';
import * as os from '@/os';
import { deviceKind } from '@/scripts/device-kind';
import MkButton from '@/components/MkButton.vue';
import { versatileLang } from '@/scripts/intl-const';
const props = withDefaults(defineProps<{
url: string;
@ -95,11 +96,9 @@ if (requestUrl.hostname === 'music.youtube.com' && requestUrl.pathname.match('^/
requestUrl.hostname = 'www.youtube.com';
}
const requestLang = (lang ?? 'ja-JP').replace('ja-KS', 'ja-JP');
requestUrl.hash = '';
window.fetch(`/url?url=${encodeURIComponent(requestUrl.href)}&lang=${requestLang}`).then(res => {
window.fetch(`/url?url=${encodeURIComponent(requestUrl.href)}&lang=${versatileLang}`).then(res => {
res.json().then(info => {
if (info.url == null) {
unknownUrl = true;

View File

@ -19,7 +19,7 @@
<script lang="ts" setup>
import XWindow from '@/components/MkWindow.vue';
import { lang } from '@/config';
import { versatileLang } from '@/scripts/intl-const';
const props = defineProps<{
url: string;
@ -35,11 +35,9 @@ let player = $ref({
height: null,
});
const requestLang = (lang ?? 'ja-JP').replace('ja-KS', 'ja-JP');
const ytFetch = (): void => {
fetching = true;
window.fetch(`/url?url=${encodeURIComponent(requestUrl.href)}&lang=${requestLang}`).then(res => {
window.fetch(`/url?url=${encodeURIComponent(requestUrl.href)}&lang=${versatileLang}`).then(res => {
res.json().then(info => {
if (info.url == null) return;
title = info.title;

View File

@ -9,6 +9,7 @@
<script lang="ts" setup>
import { onUnmounted } from 'vue';
import { i18n } from '@/i18n';
import { dateTimeFormat } from '@/scripts/intl-const';
const props = withDefaults(defineProps<{
time: Date | string;
@ -18,7 +19,7 @@ const props = withDefaults(defineProps<{
});
const _time = typeof props.time === 'string' ? new Date(props.time) : props.time;
const absolute = _time.toLocaleString();
const absolute = dateTimeFormat.format(_time);
let now = $shallowRef(new Date());
const relative = $computed(() => {