timeless

Node and browser library that helps to deal with time in timezone- and/or date- agnostic way

Timeless

Javascript (Node + Browser) library that helps to deal with time in timezone- and/or date- agnostic way

$ npm install timeless
$ ender add timeless --use=your_ender_file

– converts time string to milliseconds

Node:

var time = require('timeless');
 
time.toMilliseconds('11:23'); // -> 44580000 

Ender:

$.time.toMilliseconds('12:23:57.123'); // -> 44637123 

– parses date[time] string into timestamp (Assumes UTC, AM)

Node:

var time = require('timeless');
 
time.toTimestamp('12/31/69'); // -> 3155673600000 

Ender:

$.time.toTimestamp('8/22/13 12:30'); // -> 1377131400000 (22 Aug 2013 00:30:00 GMT) 

– returns midnight time of the specified date (strips time value from the timestamp, assumes UTC)

Node:

var time = require('timeless');
 
time.getBaseDateTime(1377174600000); // -> 1377129600000 (22 Aug 2013 12:30:00 -> 22 Aug 2013 00:00:00) 

Ender:

$.time.getBaseDateTime(3155673612345); // -> 3155673600000 (31 Dec 2069 00:00:12 -> 31 Dec 2069 00:00:00) 

– fills empty digit places with 0

Node:

var time = require('timeless');
 
time.padLeft(1); // -> '01' 

Ender:

$.time.padLeft(10); // -> '10' 

Timeless is licensed under the MIT license.