Timelite
String date and time utilities.
API
Time
-
add
: Add an array of string times. Eg.add(['04:20:10', '21:15:10'])
-
str
: Format an array of time values into string time. Eg.str([12, 0, 45])
=>[ 12, 00, 45 ]
-
sub
: Subtract an array of string times. Eg.sub(['20:05:10', '10:10:50'])
=>[ 9, 54, 20 ]
Date
-
normalize
: Normalize string date values returning a valid date as an unsigned integer array. -
str
: Format an array date values into a valid string date.
Install
yarn add timelite --dev
npm install timelite --save-dev
UMD file is also available on unpkg:
You can use the library via window.timelite
.
Usage
Time
add
Add an array of string time values "HH:mm:ss".
// [ 25, 35, 2 ]// [ 26, 10, 2 ]// [ 48, 09, 0 ]// [ 20, 00, 0 ]
sub
Subtract an array of string time values "HH:mm:ss".
// [ 0, 29, 20 ]// [ 9, 54, 20 ]
str
Format an array time values into string time.
// "12:10:45"// "05:01:00"// "07:22:00"
Date
normalize
Normalize string date values returning a valid date as an unsigned integer array.
// [ 1980, 9, 2 ]// [ 2017, 1, 1 ]// [ 2018, 4, 1 ]// [ 2000, 2, 28 ]
str
Format an array date values into a valid string date.
// 2000-01-01// 2017-12-05// 1988-02-01
Contributions
Feel free to send some Pull request or issue.
License
MIT license
© 2018 José Luis Quintana