Skip to content

Commit 8589c56

Browse files
authored
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.
1 parent e290d65 commit 8589c56

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

assets/javascripts/discourse/components/param-input-form.gjs

+1-1
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ export default class ParamInputForm extends Component {
222222
if (!value) {
223223
return null;
224224
}
225-
return moment(new Date(value).toISOString()).format("YYYY-MM-DD");
225+
return moment(value).format("YYYY-MM-DD");
226226
} catch {
227227
this.addError(info.identifier, ERRORS.INVALID_DATE(String(value)));
228228
return null;

0 commit comments

Comments
 (0)