parse-seconds

1.0.0 • Public • Published

parse-seconds

parse-seconds converts seconds into years, weeks, days, hours, and/or minutes.

This is mostly useful for formatting media durations; the larger units of time are included for completeness (maybe you have a really long video or something).

Build status

install

$ npm install parse-seconds

usage

var parse = require('parse-seconds')
 
// Basic usage
parse(60)
> {
  years: 0,
  weeks: 0,
  days: 0,
  hours: 0,
  minutes: 1,
  seconds: 0
}
 
// Avoid specific units of time
parse({ hours: false })(60 * 60 + 61)
> {
  years: 0,
  weeks: 0,
  days: 0,
  hours: 0,
  minutes: 61,
  seconds: 1
}

Readme

Keywords

Package Sidebar

Install

npm i parse-seconds

Weekly Downloads

2

Version

1.0.0

License

MIT

Last publish

Collaborators

  • michaelrhodes