duration-iso-8601
Converting ISO 8601 Duration(PnYnMnDTnHnMnS syntax)
https://en.wikipedia.org/wiki/ISO_8601#Durations
Installation
npm install duration-iso-8601 --save
Functions
convertDuration(String)
Input:
ISO 8601 Duration(PnYnMnDTnHnMnS syntax)
Output:
Object
{ year: Number, month: Number, day: Number, hour: Number, minute: Number, second: Number }
Property value will be undefined if there is no value
Return null if the input is invalid
convertToSecond(String)
Input:
ISO 8601 Duration(PnYnMnDTnHnMnS syntax)
Output:
Number of second
Return null if the input is invalid
convertYouTubeDuration(String)
Input:
ISO 8601 Duration(PnYnMnDTnHnMnS syntax)
Output:
String(hh:mm:ss) of YouTube video duration syntax
Return null if the input is invalid
Examples
; // convertDuration(String) console;// return { year: 1, month: 2, day: 3, hour: 4, minute: 5, second: 6 } console;// return { year: 1, month: undefined, day: 30, hour: undefined, minute: 15, second: 39 } console;// return null // convertToSecond(String) console;// return 3360 console;// return 7778935 console;// return null // convertYouTubeDuration(String) console;// return '3:00:00' console;// return '28:59' console;// return '0:04' console;// return null