mirror of
https://github.com/jxxghp/MoviePilot-Frontend.git
synced 2026-06-09 09:40:14 +08:00
fix subscribe
This commit is contained in:
@@ -31,3 +31,29 @@ export const isToday = (date: Date) => {
|
||||
/* eslint-enable */
|
||||
)
|
||||
}
|
||||
|
||||
export const calculateTimeDifference = (inputTime: string): string => {
|
||||
|
||||
if (!inputTime) {
|
||||
return '';
|
||||
}
|
||||
|
||||
const inputDate = new Date(inputTime);
|
||||
const currentDate = new Date();
|
||||
|
||||
const timeDifference = currentDate.getTime() - inputDate.getTime();
|
||||
const secondsDifference = Math.floor(timeDifference / 1000);
|
||||
|
||||
if (secondsDifference < 60) {
|
||||
return `${secondsDifference}秒`;
|
||||
} else if (secondsDifference < 3600) {
|
||||
const minutes = Math.floor(secondsDifference / 60);
|
||||
return `${minutes}分钟`;
|
||||
} else if (secondsDifference < 86400) {
|
||||
const hours = Math.floor(secondsDifference / 3600);
|
||||
return `${hours}小时`;
|
||||
} else {
|
||||
const days = Math.floor(secondsDifference / 86400);
|
||||
return `${days}天`;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user