diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-11-03 20:34:32 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-11-03 20:34:32 +0000 |
commit | a47bbf7ce093a46ce83cd66da5d9ce3150324860 (patch) | |
tree | 36ee17fd93f50c371dba3e8829283fa4bfb98f99 /app/assets/javascripts/lib | |
parent | 4bafeeda963a11ce4004bbe35a4ff2606bc4d10a (diff) | |
download | gitlab-ce-a47bbf7ce093a46ce83cd66da5d9ce3150324860.tar.gz |
Add latest changes from gitlab-org/gitlab@13-5-stable-ee
Diffstat (limited to 'app/assets/javascripts/lib')
-rw-r--r-- | app/assets/javascripts/lib/utils/datetime_utility.js | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/app/assets/javascripts/lib/utils/datetime_utility.js b/app/assets/javascripts/lib/utils/datetime_utility.js index 6e78dc87c02..753245147d2 100644 --- a/app/assets/javascripts/lib/utils/datetime_utility.js +++ b/app/assets/javascripts/lib/utils/datetime_utility.js @@ -658,6 +658,24 @@ export const secondsToMilliseconds = seconds => seconds * 1000; export const secondsToDays = seconds => Math.round(seconds / 86400); /** + * Converts a numeric utc offset in seconds to +/- hours + * ie -32400 => -9 hours + * ie -12600 => -3.5 hours + * + * @param {Number} offset UTC offset in seconds as a integer + * + * @return {String} the + or - offset in hours + */ +export const secondsToHours = offset => { + const parsed = parseInt(offset, 10); + if (Number.isNaN(parsed) || parsed === 0) { + return `0`; + } + const num = offset / 3600; + return parseInt(num, 10) !== num ? num.toFixed(1) : num; +}; + +/** * Returns the date n days after the date provided * * @param {Date} date the initial date |