Skip to content

For converting iso8601-duration string to and from milliseconds (JavaScript)

Notifications You must be signed in to change notification settings

rhysburnie/iso8601-duration-conversion

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Convert iso8601 Durations to and from milliseconds.

Example string: 'P0Y0M0DT0H3M30.001S'

es6

import {toMilliseconds, msToString} from 'iso8601-duration-conversion';

const ms = toMilliseconds('P0Y0M0DT0H3M30.001S');
// ms === 210001
const str = msToString(210001);
// str === 'PT3M30.001S'
// NOTE: to extraneous data in original are not included
//       because their values were 0
// therefore:
toMilliseconds('PT3M30.001S') === ('P0Y0M0DT0H3M30.001S');

common js

var iso8601DurationConverter = require('iso8601-duration-conversion');

// Same as above except use:
// iso8601DurationConverter.toMilliseconds
// iso8601DurationConverter.msToString

See index.test.js for more detail.

About

For converting iso8601-duration string to and from milliseconds (JavaScript)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published