Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-03-24 06:07:39 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2022-03-24 06:07:39 +0300
commitb132e99b27865f1e87d640ec538b282e8071ad53 (patch)
tree53bba8d95b76f3f182d20956deac51cdfbc36994 /app/assets/javascripts/lib
parent179b33c5465649ee5d020f70604f1b02473fc702 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/assets/javascripts/lib')
-rw-r--r--app/assets/javascripts/lib/utils/datetime/date_calculation_utility.js12
1 files changed, 10 insertions, 2 deletions
diff --git a/app/assets/javascripts/lib/utils/datetime/date_calculation_utility.js b/app/assets/javascripts/lib/utils/datetime/date_calculation_utility.js
index 396c1703c1e..8dbadbe4bfc 100644
--- a/app/assets/javascripts/lib/utils/datetime/date_calculation_utility.js
+++ b/app/assets/javascripts/lib/utils/datetime/date_calculation_utility.js
@@ -189,13 +189,21 @@ export const getDateInFuture = (date, daysInFuture) =>
*/
export const isValidDate = (date) => date instanceof Date && !Number.isNaN(date.getTime());
-/*
+/**
* Appending T00:00:00 makes JS assume local time and prevents it from shifting the date
* to match the user's time zone. We want to display the date in server time for now, to
* be consistent with the "edit issue -> due date" UI.
+ *
+ * @param {String} date Date without time, e.g. `2022-03-22`
+ * @return {Date} new Date object
*/
-
export const newDateAsLocaleTime = (date) => {
+ if (!date || typeof date !== 'string') {
+ return null;
+ }
+ if (date.includes('T')) {
+ return new Date(date);
+ }
const suffix = 'T00:00:00';
return new Date(`${date}${suffix}`);
};