• formats time object to string with days, hours, minutes and seconds

    Parameters

    • time: {
          days?: number;
          hours?: number;
          mins?: number;
          secs?: number;
      }

      { days, hours, mins, secs } time object defaults to 0

      • Optional days?: number
      • Optional hours?: number
      • Optional mins?: number
      • Optional secs?: number
    • Optional negative: boolean

      pass true to allow negative results (default: false)

    Returns string

    formatted time string

    Example

    formatTime({ days: 1, hours: 2, mins: 3, secs: 4 }) // '1d 2h 3m 4s'
    formatTime({ days: 1, hours: 2, mins: 3, secs: 4 }, true) // '-1d 2h 3m 4s'
    formatTime({ days: 0, hours: 0, mins: 3, secs: 4 }) // '3m 4s'
    formatTime({ days: 0, hours: 0, mins: 0, secs: 4 }) // '4s'