dlevs / duration-fns

Functions for working with durations.
MIT License
58 stars 6 forks source link

Add format() #3

Closed munierujp closed 4 years ago

munierujp commented 4 years ago

Usage:

import { parse , format } from 'duration-fns'

const duration = parse('PT1M30S')
console.log(format(duration, 'mm:ss'))  // 01:30
dlevs commented 4 years ago

Hi @munierujp,

As with #4, I think this is outside of the scope if this package. This can be achieved easily with a third party library, or plain JS.

I think libraries like "date-fns" have a compelling reason to supply a format function, since each component of a date can be expressed in many different ways. I don't see the same value in providing such a function for durations as they seem much simpler to me. If we did implement this for duration, we'd have to handle edge cases, like...

I may be looking at this from the wrong perspective. If you have any other examples or can provide more context to demonstrate the value of this, let me know.

dlevs commented 4 years ago

Closing due to lack of activity