chore (client): change variable names
This commit is contained in:
parent
9fd98cc5f7
commit
cd901cd703
1 changed files with 30 additions and 30 deletions
|
@ -52,48 +52,48 @@ const relative = computed<string>(() => {
|
||||||
if (props.mode === "absolute") return ""; // absoluteではrelativeを使わないので計算しない
|
if (props.mode === "absolute") return ""; // absoluteではrelativeを使わないので計算しない
|
||||||
if (invalid.value) return i18n.ts._ago.invalid;
|
if (invalid.value) return i18n.ts._ago.invalid;
|
||||||
|
|
||||||
const ago = Math.abs(now.value - _time.value) / 1000; /* ms */
|
const time = Math.abs(now.value - _time.value) / 1000; /* ms */
|
||||||
const agoType = now.value > _time.value ? "_ago" : "_later";
|
const agoOrLater = now.value > _time.value ? "_ago" : "_later";
|
||||||
|
|
||||||
if (ago >= 31536000) {
|
if (time >= 31536000) {
|
||||||
return i18n.t(`${agoType}.yearsAgo`, {
|
return i18n.t(`${agoOrLater}.yearsAgo`, {
|
||||||
n: Math.floor(ago / 31536000).toString(),
|
n: Math.floor(time / 31536000).toString(),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (ago >= 2592000) {
|
if (time >= 2592000) {
|
||||||
return i18n.t(`${agoType}.monthsAgo`, {
|
return i18n.t(`${agoOrLater}.monthsAgo`, {
|
||||||
n: Math.floor(ago / 2592000).toString(),
|
n: Math.floor(time / 2592000).toString(),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (ago >= 604800) {
|
if (time >= 604800) {
|
||||||
return i18n.t(`${agoType}.weeksAgo`, {
|
return i18n.t(`${agoOrLater}.weeksAgo`, {
|
||||||
n: Math.floor(ago / 604800).toString(),
|
n: Math.floor(time / 604800).toString(),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (ago >= 86400) {
|
if (time >= 86400) {
|
||||||
return i18n.t(`${agoType}.daysAgo`, {
|
return i18n.t(`${agoOrLater}.daysAgo`, {
|
||||||
n: Math.floor(ago / 86400).toString(),
|
n: Math.floor(time / 86400).toString(),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (ago >= 3600) {
|
if (time >= 3600) {
|
||||||
return i18n.t(`${agoType}.hoursAgo`, {
|
return i18n.t(`${agoOrLater}.hoursAgo`, {
|
||||||
n: Math.floor(ago / 3600).toString(),
|
n: Math.floor(time / 3600).toString(),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (ago >= 60) {
|
if (time >= 60) {
|
||||||
return i18n.t(`${agoType}.minutesAgo`, {
|
return i18n.t(`${agoOrLater}.minutesAgo`, {
|
||||||
n: (~~(ago / 60)).toString(),
|
n: (~~(time / 60)).toString(),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (ago >= 10) {
|
if (time >= 10) {
|
||||||
return i18n.t(`${agoType}.secondsAgo`, {
|
return i18n.t(`${agoOrLater}.secondsAgo`, {
|
||||||
n: (~~(ago % 60)).toString(),
|
n: (~~(time % 60)).toString(),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (ago >= -1) {
|
if (time >= -1) {
|
||||||
return i18n.ts[agoType].justNow;
|
return i18n.ts[agoOrLater].justNow;
|
||||||
}
|
}
|
||||||
return i18n.ts[agoType].future;
|
return i18n.ts[agoOrLater].future;
|
||||||
});
|
});
|
||||||
|
|
||||||
let tickId: number | undefined;
|
let tickId: number | undefined;
|
||||||
|
@ -110,13 +110,13 @@ function tick(forceUpdateTicker = false) {
|
||||||
}
|
}
|
||||||
|
|
||||||
const _now = Date.now();
|
const _now = Date.now();
|
||||||
const agoPrev = (now.value - _time.value) / 1000; /* ms */ // 現状のinterval
|
const currentInterval = (now.value - _time.value) / 1000; /* ms */
|
||||||
|
|
||||||
now.value = _now;
|
now.value = _now;
|
||||||
|
|
||||||
const ago = (now.value - _time.value) / 1000; /* ms */ // 次のinterval
|
const newInterval = (now.value - _time.value) / 1000; /* ms */
|
||||||
const prev = agoPrev < 60 ? 10000 : agoPrev < 3600 ? 60000 : 180000;
|
const prev = currentInterval < 60 ? 10000 : currentInterval < 3600 ? 60000 : 180000;
|
||||||
const next = ago < 60 ? 10000 : ago < 3600 ? 60000 : 180000;
|
const next = newInterval < 60 ? 10000 : newInterval < 3600 ? 60000 : 180000;
|
||||||
|
|
||||||
if (!tickId) {
|
if (!tickId) {
|
||||||
tickId = window.setInterval(tick, next);
|
tickId = window.setInterval(tick, next);
|
||||||
|
|
Loading…
Reference in a new issue