From 8589c56f19140b14d9a1d619457346d5db2c9b7b Mon Sep 17 00:00:00 2001 From: Gary Pendergast Date: Fri, 14 Mar 2025 14:17:14 +1100 Subject: [PATCH] FIX: Ensure dates passed in query params are parsed in the local timezone. (#365) When passing date values for reports as URL parameters, they were being parsed by the standard JavaScript Date object, which due to legacy reasons parses date-only strings in UTC, all other date formats are assumed to be in the browser's local timezone. This change switches to using moment's parser, which assumes that all strings passed to it are in the browser's local timezone. --- assets/javascripts/discourse/components/param-input-form.gjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assets/javascripts/discourse/components/param-input-form.gjs b/assets/javascripts/discourse/components/param-input-form.gjs index 5c43209..6d784b5 100644 --- a/assets/javascripts/discourse/components/param-input-form.gjs +++ b/assets/javascripts/discourse/components/param-input-form.gjs @@ -222,7 +222,7 @@ export default class ParamInputForm extends Component { if (!value) { return null; } - return moment(new Date(value).toISOString()).format("YYYY-MM-DD"); + return moment(value).format("YYYY-MM-DD"); } catch { this.addError(info.identifier, ERRORS.INVALID_DATE(String(value))); return null;