JSPM

@darkwolf/duration.cjs

1.0.3
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 14
  • Score
    100M100P100Q41704F
  • License MIT

Duration

Package Exports

  • @darkwolf/duration.cjs

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@darkwolf/duration.cjs) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Duration

Install

ECMAScript (Node.js v12.x LTS or higher)

npm i --save @darkwolf/duration.mjs

CommonJS (Node.js v10.x LTS or higher)

npm i --save @darkwolf/duration.cjs

Using

// ECMAScript
import Duration from '@darkwolf/duration.mjs'

// CommonJS
const Duration = require('@darkwolf/duration.cjs')

Duration.parse('23h 59min 59sec') // => 86399000
Duration.parse('-23h 59min 59sec') // => -86399000
Duration.ms('23ч 59мин 59сек') // => 86399000
Duration.sec('23ч 59мин 59сек') // => 86399
const duration = new Duration('23h 59min 59sec')
duration.toString({millis: false}) // => '23:59:59'
duration.toLocaleString() // => '23 hours 59 minutes 59 seconds'
duration.toLocaleString('ru', {style: 'short'}) // => '23 ч. 59 мин. 59 сек.'
duration
  .add('1 second')
  .subtract('.5 day')
duration.value // => 43200000
const other = duration
  .clone()
  .add('12 hours')
other.value // => 86400000
const sum = duration + other // => 129600000

API Documentation

Contact Me

GitHub: @PavelWolfDark

Telegram: @PavelWolfDark

Email: PavelWolfDark@gmail.com