1.0.0 • Published 9 years ago

parse-seconds v1.0.0

Weekly downloads
7
License
MIT
Repository
github
Last release
9 years ago

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
}