diff options
Diffstat (limited to 'app/assets/javascripts/lib/utils/datetime')
-rw-r--r-- | app/assets/javascripts/lib/utils/datetime/date_calculation_utility.js | 9 | ||||
-rw-r--r-- | app/assets/javascripts/lib/utils/datetime/date_format_utility.js | 27 |
2 files changed, 24 insertions, 12 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 d52672b9d08..4e0d19f2c2a 100644 --- a/app/assets/javascripts/lib/utils/datetime/date_calculation_utility.js +++ b/app/assets/javascripts/lib/utils/datetime/date_calculation_utility.js @@ -133,7 +133,8 @@ export const dayInQuarter = (date, quarter) => { return quarter.reduce((acc, month) => { if (dateValues.month > month.getMonth()) { return acc + totalDaysInMonth(month); - } else if (dateValues.month === month.getMonth()) { + } + if (dateValues.month === month.getMonth()) { return acc + dateValues.date; } return acc + 0; @@ -562,9 +563,11 @@ export const approximateDuration = (seconds = 0) => { if (seconds < 30) { return __('less than a minute'); - } else if (seconds < MINUTES_LIMIT) { + } + if (seconds < MINUTES_LIMIT) { return n__('1 minute', '%d minutes', seconds < ONE_MINUTE_LIMIT ? 1 : minutes); - } else if (seconds < HOURS_LIMIT) { + } + if (seconds < HOURS_LIMIT) { return n__('about 1 hour', 'about %d hours', seconds < ONE_HOUR_LIMIT ? 1 : hours); } return n__('1 day', '%d days', seconds < ONE_DAY_LIMIT ? 1 : days); diff --git a/app/assets/javascripts/lib/utils/datetime/date_format_utility.js b/app/assets/javascripts/lib/utils/datetime/date_format_utility.js index b0264796d90..c4b8f95e99f 100644 --- a/app/assets/javascripts/lib/utils/datetime/date_format_utility.js +++ b/app/assets/javascripts/lib/utils/datetime/date_format_utility.js @@ -93,10 +93,12 @@ export const humanizeTimeInterval = (intervalInSeconds) => { if (intervalInSeconds < 60 /* = 1 minute */) { const seconds = Math.round(intervalInSeconds * 10) / 10; return n__('%d second', '%d seconds', seconds); - } else if (intervalInSeconds < 3600 /* = 1 hour */) { + } + if (intervalInSeconds < 3600 /* = 1 hour */) { const minutes = Math.round(intervalInSeconds / 6) / 10; return n__('%d minute', '%d minutes', minutes); - } else if (intervalInSeconds < 86400 /* = 1 day */) { + } + if (intervalInSeconds < 86400 /* = 1 day */) { const hours = Math.round(intervalInSeconds / 360) / 10; return n__('%d hour', '%d hours', hours); } @@ -378,19 +380,24 @@ export const formatTimeAsSummary = ({ seconds, hours, days, minutes, weeks, mont return sprintf(s__('ValueStreamAnalytics|%{value}M'), { value: roundToNearestHalf(months), }); - } else if (weeks) { + } + if (weeks) { return sprintf(s__('ValueStreamAnalytics|%{value}w'), { value: roundToNearestHalf(weeks), }); - } else if (days) { + } + if (days) { return sprintf(s__('ValueStreamAnalytics|%{value}d'), { value: roundToNearestHalf(days), }); - } else if (hours) { + } + if (hours) { return sprintf(s__('ValueStreamAnalytics|%{value}h'), { value: hours }); - } else if (minutes) { + } + if (minutes) { return sprintf(s__('ValueStreamAnalytics|%{value}m'), { value: minutes }); - } else if (seconds) { + } + if (seconds) { return unescape(sanitize(s__('ValueStreamAnalytics|<1m'), { ALLOWED_TAGS: [] })); } return '-'; @@ -441,11 +448,13 @@ export const humanTimeframe = (startDate, dueDate) => { startDate: startDateInWords, dueDate: dueDateInWords, }); - } else if (startDate && !dueDate) { + } + if (startDate && !dueDate) { return sprintf(__('%{startDate} – No due date'), { startDate: dateInWords(start, true, false), }); - } else if (!startDate && dueDate) { + } + if (!startDate && dueDate) { return sprintf(__('No start date – %{dueDate}'), { dueDate: dateInWords(due, true, false), }); |