diff options
author | Bryce Johnson <bryce@gitlab.com> | 2017-08-31 22:07:57 +0300 |
---|---|---|
committer | Bryce Johnson <bryce@gitlab.com> | 2017-08-31 22:07:57 +0300 |
commit | dde56a783752a08561b19cf3b7d0f53635801002 (patch) | |
tree | 8c9db7be133f27f667ed23468417ca7a1f161a1a /app | |
parent | e58428382265f02639a7fc8c1bfcc6311564c0d0 (diff) |
Add support for custom daysPerWeek and hoursPerDay to prettyTime.parseSeconds.
Diffstat (limited to 'app')
-rw-r--r-- | app/assets/javascripts/lib/utils/pretty_time.js | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/app/assets/javascripts/lib/utils/pretty_time.js b/app/assets/javascripts/lib/utils/pretty_time.js index 716aefbfcb7..227bf65b560 100644 --- a/app/assets/javascripts/lib/utils/pretty_time.js +++ b/app/assets/javascripts/lib/utils/pretty_time.js @@ -2,19 +2,20 @@ import _ from 'underscore'; (() => { /* - * TODO: Make these methods more configurable (e.g. parseSeconds timePeriodContstraints, - * stringifyTime condensed or non-condensed, abbreviateTimelengths) + * TODO: Make these methods more configurable (e.g. stringifyTime condensed or + * non-condensed, abbreviateTimelengths) * */ const utils = window.gl.utils = gl.utils || {}; const prettyTime = utils.prettyTime = { /* * Accepts seconds and returns a timeObject { weeks: #, days: #, hours: #, minutes: # } - * Seconds can be negative or positive, zero or non-zero. + * Seconds can be negative or positive, zero or non-zero. Can be configured for any day + * or week length. */ - parseSeconds(seconds) { - const DAYS_PER_WEEK = 5; - const HOURS_PER_DAY = 8; + parseSeconds(seconds, { daysPerWeek = 5, hoursPerDay = 8 } = {}) { + const DAYS_PER_WEEK = daysPerWeek; + const HOURS_PER_DAY = hoursPerDay; const MINUTES_PER_HOUR = 60; const MINUTES_PER_WEEK = DAYS_PER_WEEK * HOURS_PER_DAY * MINUTES_PER_HOUR; const MINUTES_PER_DAY = HOURS_PER_DAY * MINUTES_PER_HOUR; |