From 8a7eefb3ec73a4119295715975050f22214a5678 Mon Sep 17 00:00:00 2001 From: "gpt-engineer-app[bot]" <159125892+gpt-engineer-app[bot]@users.noreply.github.com> Date: Fri, 24 Apr 2026 13:59:15 +0000 Subject: [PATCH] Changes Co-authored-by: renee-png <262607627+renee-png@users.noreply.github.com> --- src/lib/workflow-chain.ts | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/lib/workflow-chain.ts b/src/lib/workflow-chain.ts index 660dedd..ea015b8 100644 --- a/src/lib/workflow-chain.ts +++ b/src/lib/workflow-chain.ts @@ -1,5 +1,17 @@ import { supabase } from "@/integrations/supabase/client"; -import { addDays, format } from "date-fns"; +import { addDays } from "date-fns"; + +/** + * Format a Date as "YYYY-MM-DD" using its UTC components. We do this so that + * a `completed_at` UTC timestamp like 2026-04-24T02:00:00Z (which is still + * Apr 23 in US local time) doesn't shift the computed due_date back a day. + */ +function toUTCDateString(d: Date): string { + const y = d.getUTCFullYear(); + const m = String(d.getUTCMonth() + 1).padStart(2, "0"); + const day = String(d.getUTCDate()).padStart(2, "0"); + return `${y}-${m}-${day}`; +} /** * After a task is marked complete, spawn the next task from its workflow @@ -48,7 +60,7 @@ export async function spawnNextWorkflowTask(taskId: string): Promise