timezone
This commit is contained in:
@@ -37,9 +37,12 @@ export async function POST(req: Request) {
|
||||
const body = await req.json();
|
||||
const { managerName, date } = body;
|
||||
|
||||
// Check if a report already exists for this date and user
|
||||
const reportDate = date ? new Date(date) : new Date();
|
||||
reportDate.setHours(0, 0, 0, 0);
|
||||
// Check if a report already exists for this date and user.
|
||||
// Client always sends a YYYY-MM-DD date string in Central US time;
|
||||
// we store it as UTC midnight so the date string is stable across timezones.
|
||||
const reportDate = date
|
||||
? new Date(`${date}T00:00:00.000Z`)
|
||||
: new Date(new Date().toLocaleDateString('en-CA', { timeZone: 'America/Chicago' }) + 'T00:00:00.000Z');
|
||||
|
||||
let report = await prisma.report.findFirst({
|
||||
where: {
|
||||
|
||||
Reference in New Issue
Block a user