first commit
This commit is contained in:
16
frontend/app/utils/function/projectDuration/index.tsx
Normal file
16
frontend/app/utils/function/projectDuration/index.tsx
Normal file
@@ -0,0 +1,16 @@
|
||||
export function calculateDurationInDays(
|
||||
startDate?: string | Date,
|
||||
endDate?: string | Date
|
||||
): number | null {
|
||||
if (!startDate || !endDate) return null;
|
||||
|
||||
const start = new Date(startDate);
|
||||
const end = new Date(endDate);
|
||||
|
||||
if (isNaN(start.getTime()) || isNaN(end.getTime())) return null;
|
||||
|
||||
const diffTime = end.getTime() - start.getTime();
|
||||
const diffDays = Math.ceil(diffTime / (1000 * 60 * 60 * 24));
|
||||
|
||||
return diffDays >= 0 ? diffDays : null;
|
||||
}
|
||||
Reference in New Issue
Block a user