mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-22 19:32:54 +03:00
Fixed time not being converted properly
ref https://linear.app/tryghost/issue/AP-131/show-nice-relative-timestamps
This commit is contained in:
parent
2a212bfff4
commit
366d683d7b
@ -3,12 +3,12 @@ export const getRelativeTimestamp = (date: Date): string => {
|
||||
const seconds = Math.floor((now.getTime() - date.getTime()) / 1000);
|
||||
|
||||
let interval = Math.floor(seconds / 31536000);
|
||||
if (interval > 1) {
|
||||
if (interval >= 1) {
|
||||
return `${interval}y`;
|
||||
}
|
||||
|
||||
interval = Math.floor(seconds / 2592000);
|
||||
if (interval > 1) {
|
||||
if (interval >= 1) {
|
||||
return `${interval}m`;
|
||||
}
|
||||
|
||||
@ -18,12 +18,12 @@ export const getRelativeTimestamp = (date: Date): string => {
|
||||
}
|
||||
|
||||
interval = Math.floor(seconds / 3600);
|
||||
if (interval > 1) {
|
||||
if (interval >= 1) {
|
||||
return `${interval}h`;
|
||||
}
|
||||
|
||||
interval = Math.floor(seconds / 60);
|
||||
if (interval > 1) {
|
||||
if (interval >= 1) {
|
||||
return `${interval}m`;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user