summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/lib/utils
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-03-11 09:09:48 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-03-11 09:09:48 +0000
commit3f3e4bcc50a3280d03299c2c263eafd9c8e3bd7b (patch)
treeeccfc6b87b404f2871cc795bf2f7223a7e391939 /app/assets/javascripts/lib/utils
parent65a1175e466105fca1f40cb5a995fdb100ff334e (diff)
downloadgitlab-ce-3f3e4bcc50a3280d03299c2c263eafd9c8e3bd7b.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/assets/javascripts/lib/utils')
-rw-r--r--app/assets/javascripts/lib/utils/datetime_utility.js8
1 files changed, 8 insertions, 0 deletions
diff --git a/app/assets/javascripts/lib/utils/datetime_utility.js b/app/assets/javascripts/lib/utils/datetime_utility.js
index a70bab013c6..f6077673ad5 100644
--- a/app/assets/javascripts/lib/utils/datetime_utility.js
+++ b/app/assets/javascripts/lib/utils/datetime_utility.js
@@ -566,6 +566,14 @@ export const getDateInPast = (date, daysInPast) =>
export const getDateInFuture = (date, daysInFuture) =>
new Date(newDate(date).setDate(date.getDate() + daysInFuture));
+/**
+ * Checks if a given date-instance was created with a valid date
+ *
+ * @param {Date} date
+ * @returns boolean
+ */
+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