mirror of
https://github.com/sim1222/misskey.git
synced 2025-04-29 02:37:22 +09:00
fix relative time display
This commit is contained in:
parent
29831ee426
commit
bf4b465c36
@ -24,10 +24,6 @@ let now = $shallowRef(new Date());
|
|||||||
const relative = $computed(() => {
|
const relative = $computed(() => {
|
||||||
const ago = (now.getTime() - _time.getTime()) / 1000/*ms*/;
|
const ago = (now.getTime() - _time.getTime()) / 1000/*ms*/;
|
||||||
return (
|
return (
|
||||||
// ago >= 31536000 ? i18n.t('_ago.yearsAgo', { n: Math.round(ago / 31536000).toString() }) :
|
|
||||||
// ago >= 2592000 ? i18n.t('_ago.monthsAgo', { n: Math.round(ago / 2592000).toString() }) :
|
|
||||||
// ago >= 604800 ? i18n.t('_ago.weeksAgo', { n: Math.round(ago / 604800).toString() }) :
|
|
||||||
// ago >= 86400 ? i18n.t('_ago.daysAgo', { n: Math.round(ago / 86400).toString() }) :
|
|
||||||
ago >= 86400 ? _time.toLocaleDateString() :
|
ago >= 86400 ? _time.toLocaleDateString() :
|
||||||
ago >= 3600 ? i18n.t('_ago.hoursAgo', { n: Math.round(ago / 3600).toString() }) :
|
ago >= 3600 ? i18n.t('_ago.hoursAgo', { n: Math.round(ago / 3600).toString() }) :
|
||||||
ago >= 60 ? i18n.t('_ago.minutesAgo', { n: (~~(ago / 60)).toString() }) :
|
ago >= 60 ? i18n.t('_ago.minutesAgo', { n: (~~(ago / 60)).toString() }) :
|
||||||
@ -36,6 +32,20 @@ const relative = $computed(() => {
|
|||||||
i18n.ts._ago.future);
|
i18n.ts._ago.future);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const allRelative = $computed(() => {
|
||||||
|
const ago = (now.getTime() - _time.getTime()) / 1000/*ms*/;
|
||||||
|
return (
|
||||||
|
ago >= 31536000 ? i18n.t('_ago.yearsAgo', { n: Math.round(ago / 31536000).toString() }) :
|
||||||
|
ago >= 2592000 ? i18n.t('_ago.monthsAgo', { n: Math.round(ago / 2592000).toString() }) :
|
||||||
|
ago >= 604800 ? i18n.t('_ago.weeksAgo', { n: Math.round(ago / 604800).toString() }) :
|
||||||
|
ago >= 86400 ? i18n.t('_ago.daysAgo', { n: Math.round(ago / 86400).toString() }) :
|
||||||
|
ago >= 3600 ? i18n.t('_ago.hoursAgo', { n: Math.round(ago / 3600).toString() }) :
|
||||||
|
ago >= 60 ? i18n.t('_ago.minutesAgo', { n: (~~(ago / 60)).toString() }) :
|
||||||
|
ago >= 10 ? i18n.t('_ago.secondsAgo', { n: (~~(ago % 60)).toString() }) :
|
||||||
|
ago >= -1 ? i18n.ts._ago.justNow :
|
||||||
|
i18n.ts._ago.future);
|
||||||
|
});
|
||||||
|
|
||||||
function tick() {
|
function tick() {
|
||||||
// TODO: パフォーマンス向上のため、このコンポーネントが画面内に表示されている場合のみ更新する
|
// TODO: パフォーマンス向上のため、このコンポーネントが画面内に表示されている場合のみ更新する
|
||||||
now = new Date();
|
now = new Date();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user