timeless

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

npm install timeless
1 downloads in the last day
1 downloads in the last week
9 downloads in the last month

Timeless Build Status Dependency Status

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

Install

Node

$ npm install timeless

Ender

$ ender add timeless --use=your_ender_file

Usage

toMilliseconds

– converts time string to milliseconds

Node:

var time = require('timeless');

time.toMilliseconds('11:23'); // -> 44580000

Ender:

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

toTimestamp

– 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)

getBaseDateTime

– 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)

padLeft

– fills empty digit places with 0

Node:

var time = require('timeless');

time.padLeft(1); // -> '01'

Ender:

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

License

Timeless is licensed under the MIT license.

npm loves you