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

time_spent_utility.js « datetime « utils « lib « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 64c77bf10808f81fcfa4205fc4e95fc8b411fa6e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
import { stringifyTime, parseSeconds } from './date_format_utility';

/**
 * Formats seconds into a human readable value of elapsed time,
 * optionally limiting it to hours.
 * @param {Number} seconds Seconds to format
 * @param {Boolean} limitToHours Whether or not to limit the elapsed time to be expressed in hours
 * @return {String} Provided seconds in human readable elapsed time format
 */
export const formatTimeSpent = (seconds, limitToHours) => {
  const negative = seconds < 0;
  return (negative ? '- ' : '') + stringifyTime(parseSeconds(seconds, { limitToHours }));
};