From 12e9d842aa71f646a60ce1ed948b2c29f0eb860a Mon Sep 17 00:00:00 2001 From: 7PH Date: Tue, 4 Jul 2023 12:27:31 -0300 Subject: [PATCH] SONAR-19620 Fix invalid license date expiration due to date format --- server/sonar-web/src/main/js/helpers/query.ts | 10 +++++++--- 1 file 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; -- 2.39.5