diff options
Diffstat (limited to 'server')
-rw-r--r-- | server/sonar-web/src/main/js/helpers/query.ts | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/server/sonar-web/src/main/js/helpers/query.ts b/server/sonar-web/src/main/js/helpers/query.ts index f332c3117a7..615534add4e 100644 --- a/server/sonar-web/src/main/js/helpers/query.ts +++ b/server/sonar-web/src/main/js/helpers/query.ts @@ -57,9 +57,13 @@ export function parseAsOptionalBoolean(value: string | undefined): boolean | und export function parseAsDate(value?: string): Date | undefined { if (value) { - // We atttemp to parse date that does not have time. - // Otherwise date will create a date at midnight UTC - // and it does not play well when we get the local day. + /** + * When the time zone offset is absent, date-only forms are interpreted as a UTC time + * and date-time forms are interpreted as local time. + * To ensure we always parse dates as date-time, we first try and add the time to the date, + * and if it fails, we try and parse the date as is. + * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date + */ let date = parseDate(value + ' 00:00:00'); if (isValidDate(date)) { return date; |