แก้ไข return null เมื่อวันที่ไม่สอดคล้อง

This commit is contained in:
AnandaTon 2024-05-17 15:34:21 +07:00
parent 71cbecdce0
commit 9b85f0d021

View file

@ -1,5 +1,5 @@
export function calculateAge(start: Date, end = new Date()) {
if (start.getTime() > end.getTime()) return;
if (start.getTime() > end.getTime()) return null;
let year = end.getFullYear() - start.getFullYear();
let month = end.getMonth() - start.getMonth();