mirror of
https://github.com/usual2970/certimate.git
synced 2025-06-09 05:59:50 +00:00
Merge pull request #222 from usual2970/feat/cert-leftday
Add remaining days
This commit is contained in:
commit
364289894e
@ -21,6 +21,16 @@ export const getDate = (zuluTime: string) => {
|
||||
return time.split(" ")[0];
|
||||
};
|
||||
|
||||
export const getLeftDays = (zuluTime: string) => {
|
||||
const time = convertZulu2Beijing(zuluTime);
|
||||
const date = time.split(" ")[0];
|
||||
const now = new Date();
|
||||
const target = new Date(date);
|
||||
const diff = target.getTime() - now.getTime();
|
||||
const days = Math.floor(diff / (1000 * 60 * 60 * 24));
|
||||
return days;
|
||||
};
|
||||
|
||||
export function getTimeBefore(days: number): string {
|
||||
// 获取当前时间
|
||||
const currentDate = new Date();
|
||||
@ -66,3 +76,4 @@ export function getTimeAfter(days: number): string {
|
||||
|
||||
return formattedDate;
|
||||
}
|
||||
|
||||
|
@ -26,7 +26,7 @@ import { Toaster } from "@/components/ui/toaster";
|
||||
import { Tooltip, TooltipTrigger } from "@/components/ui/tooltip";
|
||||
import { useToast } from "@/components/ui/use-toast";
|
||||
import { CustomFile, saveFiles2ZIP } from "@/lib/file";
|
||||
import { convertZulu2Beijing, getDate } from "@/lib/time";
|
||||
import { convertZulu2Beijing, getDate, getLeftDays } from "@/lib/time";
|
||||
import { Domain } from "@/domain/domain";
|
||||
import { list, remove, save, subscribeId, unsubscribeId } from "@/repository/domains";
|
||||
|
||||
@ -213,7 +213,7 @@ const Home = () => {
|
||||
<div>
|
||||
{domain.expiredAt ? (
|
||||
<>
|
||||
<div>{t("domain.props.expiry.date1", { date: 90 })}</div>
|
||||
<div>{t("domain.props.expiry.date1", { date: `${getLeftDays(domain.expiredAt)}/90` })}</div>
|
||||
<div>
|
||||
{t("domain.props.expiry.date2", {
|
||||
date: getDate(domain.expiredAt),
|
||||
@ -340,3 +340,4 @@ const Home = () => {
|
||||
};
|
||||
|
||||
export default Home;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user