diff --git a/dist/index.html b/dist/index.html
index c43abbb8..40e9d2e6 100644
--- a/dist/index.html
+++ b/dist/index.html
@@ -6,7 +6,7 @@
Todo App
-
+
diff --git a/src/lib/utils.ts b/src/lib/utils.ts
index 9d7756f4..6b8674df 100644
--- a/src/lib/utils.ts
+++ b/src/lib/utils.ts
@@ -8,12 +8,13 @@ export function cn(...inputs: ClassValue[]) {
export function formatDate(date: string | Date | undefined): string {
if (!date) return '';
+ // Parse as UTC to avoid timezone shift (due dates are date-only values stored as midnight UTC)
const d = new Date(date);
const now = new Date();
const today = new Date(now.getFullYear(), now.getMonth(), now.getDate());
const tomorrow = new Date(today);
tomorrow.setDate(tomorrow.getDate() + 1);
- const taskDate = new Date(d.getFullYear(), d.getMonth(), d.getDate());
+ const taskDate = new Date(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate());
if (taskDate.getTime() === today.getTime()) {
return 'Today';
@@ -32,23 +33,25 @@ export function formatDate(date: string | Date | undefined): string {
const weekFromNow = new Date(today);
weekFromNow.setDate(weekFromNow.getDate() + 7);
if (taskDate > today && taskDate < weekFromNow) {
- return d.toLocaleDateString('en-US', { weekday: 'long' });
+ return taskDate.toLocaleDateString('en-US', { weekday: 'long' });
}
// Same year
- if (d.getFullYear() === now.getFullYear()) {
- return d.toLocaleDateString('en-US', { month: 'short', day: 'numeric' });
+ if (taskDate.getFullYear() === now.getFullYear()) {
+ return taskDate.toLocaleDateString('en-US', { month: 'short', day: 'numeric' });
}
- return d.toLocaleDateString('en-US', { month: 'short', day: 'numeric', year: 'numeric' });
+ return taskDate.toLocaleDateString('en-US', { month: 'short', day: 'numeric', year: 'numeric' });
}
export function isOverdue(date: string | Date | undefined): boolean {
if (!date) return false;
+ // Parse as UTC to avoid timezone shift
const d = new Date(date);
+ const taskDate = new Date(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate());
const today = new Date();
today.setHours(0, 0, 0, 0);
- return d < today;
+ return taskDate < today;
}
export function getPriorityColor(priority: string): string {