refactor: move function to utile
This commit is contained in:
parent
1a2d5ed502
commit
03d0916f26
2 changed files with 11 additions and 9 deletions
|
|
@ -1,16 +1,9 @@
|
|||
<script lang="ts" setup>
|
||||
import { calculateDaysUntilExpire } from 'stores/utils';
|
||||
|
||||
defineProps<{
|
||||
expirationDate: Date;
|
||||
}>();
|
||||
|
||||
function calculateDaysUntilExpire(expireDate: Date): number {
|
||||
const today = new Date();
|
||||
const expire = new Date(expireDate);
|
||||
const diffInTime = expire.getTime() - today.getTime();
|
||||
const diffInDays = Math.ceil(diffInTime / (1000 * 60 * 60 * 24));
|
||||
|
||||
return diffInDays;
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
|
|
|||
|
|
@ -495,4 +495,13 @@ export async function getAttachmentHead(api: AxiosInstance, url: string) {
|
|||
if (res) return res.headers;
|
||||
}
|
||||
|
||||
export function calculateDaysUntilExpire(expireDate: Date): number {
|
||||
const today = new Date();
|
||||
const expire = new Date(expireDate);
|
||||
const diffInTime = expire.getTime() - today.getTime();
|
||||
const diffInDays = Math.ceil(diffInTime / (1000 * 60 * 60 * 24));
|
||||
|
||||
return diffInDays;
|
||||
}
|
||||
|
||||
export default useUtilsStore;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue