[offers][fix] fix date display for single value (#481)

pull/482/head
Zhang Ziqing 2 years ago committed by GitHub
parent d4283eb522
commit 6c53956551
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -9,19 +9,23 @@ export function timeSinceNow(date: Date | number | string) {
let interval = seconds / 31536000;
if (interval > 1) {
return `${Math.floor(interval)} years`;
const time: number = Math.floor(interval);
return time === 1 ? `${time} year` : `${time} years`;
}
interval = seconds / 2592000;
if (interval > 1) {
return `${Math.floor(interval)} months`;
const time: number = Math.floor(interval);
return time === 1 ? `${time} month` : `${time} months`;
}
interval = seconds / 86400;
if (interval > 1) {
return `${Math.floor(interval)} days`;
const time: number = Math.floor(interval);
return time === 1 ? `${time} day` : `${time} days`;
}
interval = seconds / 3600;
if (interval > 1) {
return `${Math.floor(interval)} hours`;
const time: number = Math.floor(interval);
return time === 1 ? `${time} hour` : `${time} hours`;
}
interval = seconds / 60;
if (interval > 1) {

Loading…
Cancel
Save