From f400af76af6f97a77f9564aa446a6a40cf19292f Mon Sep 17 00:00:00 2001 From: Jeff Sieu Date: Tue, 8 Nov 2022 01:51:16 +0800 Subject: [PATCH] [questions][fix] use UTC time for month and year --- .../questions/forms/ContributeQuestionForm.tsx | 15 ++++++--------- .../forms/CreateQuestionEncounterForm.tsx | 2 +- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/apps/portal/src/components/questions/forms/ContributeQuestionForm.tsx b/apps/portal/src/components/questions/forms/ContributeQuestionForm.tsx index c69cf81c..02ac6647 100644 --- a/apps/portal/src/components/questions/forms/ContributeQuestionForm.tsx +++ b/apps/portal/src/components/questions/forms/ContributeQuestionForm.tsx @@ -151,7 +151,9 @@ export default function ContributeQuestionForm({ }} yearRequired={true} onChange={({ month, year }) => { - field.onChange(startOfMonth(new Date(year!, month! - 1))); + field.onChange( + new Date(Date.UTC(year!, month! - 1, 1, 0, 0, 0, 0)), + ); }} /> )} @@ -266,18 +268,13 @@ export default function ContributeQuestionForm({ />
- + + variant="primary" + />
diff --git a/apps/portal/src/components/questions/forms/CreateQuestionEncounterForm.tsx b/apps/portal/src/components/questions/forms/CreateQuestionEncounterForm.tsx index f158ede5..7519f06c 100644 --- a/apps/portal/src/components/questions/forms/CreateQuestionEncounterForm.tsx +++ b/apps/portal/src/components/questions/forms/CreateQuestionEncounterForm.tsx @@ -130,7 +130,7 @@ export default function CreateQuestionEncounterForm({ yearLabel="" onChange={(value) => { setSelectedDate( - startOfMonth(new Date(value.year!, value.month! - 1)), + new Date(Date.UTC(value.year!, value.month! - 1, 1, 0, 0, 0, 0)), ); }} />