All files / addon/utils create-time-object.js

100% Statements 1/1
100% Branches 0/0
100% Functions 1/1
100% Lines 1/1

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37                                                            24x            
import zeroify from './zeroify';
 
/**
 * @public
 * @class utils
 */
 
/**
 * Value is an object containing a duration in three formats.
 * The three formats are `raw`, `string`, and `pojo`.
 *
 * Duration of 6 minutes would be output as:
 *
 *     {
 *       raw: 360, // seconds
 *       string: '06:00',
 *       pojo: {
 *         minutes: 6,
 *         seconds: 0
 *       }
 *     }
 *
 * @public
 * @method createTimeObject
 * @param {number} input A number that should be formatted
 * @param {number} minutes The number of minutes in the duration
 * @param {number} seconds The number of seconds (in addition to minutes) in the duration
 * @return {object} A POJO containing the input time in 3 forms
 */
export default function createTimeObject(raw, minutes, seconds) {
  return {
    raw,
    string: `${zeroify(minutes)}:${zeroify(seconds)}`,
    pojo: { minutes, seconds },
  };
}