0.5.2 • Published 10 years ago
tmg v0.5.2
tmg 
Timer generator
tmg-cli - CLI for this module
Install
npm install --save tmgUsage
var tmg = require('tmg');
var date = new Date(2018, 05, 01, 12, 0, 0);
tmg(date)
.format('h:mm:ss')
.start(function(t) {
t.toString();
});API
tmg(date)
Return timer, default new Date()
var timer = tmg();
var countdown = tmg(new Date(2018, 05, 01, 12, 0, 0));.format(str)
Set format string
tmg().format('D [days] h:mm:ss'); // 4 days 2:00:15Can be used:
D- daysh,hh- hoursm,mm- minutess,ss- seconds[escaped]- escaped text
.start(fn)
Start timer interval
timer.start(function(t) {
t.toString(); // '12:00:10'
});.end()
Clear timer interval
.toObject(str)
Return object with current timer value with local format str
timer.toObject(); // {h: 12, m: 0, s: 10}
timer.toObject('m:s'); // {m: 720, s: 10}.toArray(str)
Return object with current timer value with local format str
timer.toArray(); // [12, 0, 10]
timer.toArray('m:s'); // [720, 10].toString(str)
Return string with current timer value with local format str
timer.toString(); // '12:00:10'
timer.toString('mm:ss'); // '720:10'License
MIT