Timelite
String date and time utilities.
API
Time
Date
Install
Yarn
yarn add timelite --dev
NPM
npm install timelite --save-dev
UMD file is also available on unpkg:
<script src="https://unpkg.com/timelite/timelite.umd.min.js"></script>
You can use the library via window.timelite
.
Usage
Time
add
Add an array of string time values "HH:mm:ss".
import { add } from 'timelite/time'
add(['04:20:10', '21:15:10'])
add(['04:35:10', '21:35:10'])
add(['30:59', '17:10'])
add(['19:30:00', '00:30:00'])
sub
Subtract an array of string time values "HH:mm:ss".
import { sub } from 'timelite/time'
sub(['20:40:10', '20:10:50'])
sub(['20:05:10', '10:10:50'])
str
Format an array time values into string time.
import { str } from 'timelite/time'
str([12, 10, 45])
str([5, 1, 0])
str([7, 22])
Date
normalize
Normalize string date values returning a valid date as an unsigned integer array.
import { normalize } from 'timelite/date'
normalize('1980-09-02')
normalize('17')
normalize('18-04')
normalize('0-02-31')
str
Format an array date values into a valid string date.
import { str } from 'timelite/date'
str([ 0, 0, 0 ])
str([ 17, 14, 5 ])
str([ 1988, 2 ])
Contributions
Feel free to send some Pull request or issue.
License
MIT license
© 2018 José Luis Quintana