From f8cc453d7eae11e61a51d24cee7bc5d7697ba269 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A2u=20Cao?= Date: Fri, 30 Dec 2022 22:20:16 +0700 Subject: [PATCH] Fix timezone issue in expense item form Dates being added with 00:00 time still carry the timezone set for the OS/browser, and thus get changed to the previous day when in a positive offset zone. This change removes the timezone offset entirely when adding the line item, so that the chosen date is always assumed to be in UTC time. fixes #204 --- app/components/add-expense-item/component.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/components/add-expense-item/component.js b/app/components/add-expense-item/component.js index 66512fa..72790e6 100644 --- a/app/components/add-expense-item/component.js +++ b/app/components/add-expense-item/component.js @@ -63,7 +63,10 @@ export default class AddExpenseItemComponent extends Component { let dateInput = (this.date instanceof Array) ? this.date[0] : this.date; - const [ date ] = dateInput.toISOString().split('T'); + + const [ date ] = moment(dateInput).utcOffset(0, true) + .toISOString() + .split('T'); const isValid = this.validateForm(); if (!isValid) return false;