fix: nonblock-statement-body-position lint in time.vue

This commit is contained in:
Norm 2022-08-19 14:43:52 -04:00
parent 0965d3cbd9
commit fd2028df48
Signed by untrusted user: norm
GPG key ID: 7123E30E441E80DE

View file

@ -36,22 +36,26 @@ let now = $ref(new Date());
const relative = $computed(() => {
const ago = (now.getTime() - _time.getTime()) / 1000/*ms*/;
if (ago >= 31536000)
if (ago >= 31536000) {
return i18n.t('_ago.yearsAgo', { n: Math.round(ago / 31536000).toString() });
if (ago >= 2592000)
} else if (ago >= 2592000) {
return i18n.t('_ago.monthsAgo', { n: Math.round(ago / 2592000).toString() });
if (ago >= 604800)
} else if (ago >= 604800) {
return i18n.t('_ago.weeksAgo', { n: Math.round(ago / 604800).toString() });
if (ago >= 86400)
} else if (ago >= 86400) {
return i18n.t('_ago.daysAgo', { n: Math.round(ago / 86400).toString() });
}
// if the format is 'date', the relative date precision is no more than days ago
if (props.format !== 'date' && ago >= 3600)
return i18n.t('_ago.hoursAgo', { n: Math.round(ago / 3600).toString() });
if (props.format !== 'date' && ago >= 60)
return i18n.t('_ago.minutesAgo', { n: (~~(ago / 60)).toString() });
if (props.format !== 'date' && ago >= 10)
return i18n.t('_ago.secondsAgo', { n: (~~(ago % 60)).toString() });
if (props.format !== 'date') {
if (ago >= 3600) {
return i18n.t('_ago.hoursAgo', { n: Math.round(ago / 3600).toString() });
} else if (ago >= 60) {
return i18n.t('_ago.minutesAgo', { n: (~~(ago / 60)).toString() });
} else if (ago >= 10) {
return i18n.t('_ago.secondsAgo', { n: (~~(ago % 60)).toString() });
}
}
if (ago >= -5) {
if (props.format === 'date') {