Skip to content

flesler/jsTime

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

JS Time

##Works both on Node and the browser

require('./lib/jsTime.js');
<script type="type/javascript" src="js/jsTime.js"></ script>

##After that you can do things like these:

setTimeout(function(){
	alert('After 10 seconds');
}, 10..seconds());

setInterval(function(){
	alert('Every 1.5 minutes');
}, 1.5.minutes());

// Timestamp of 3 days from now
var expire = new Date() + 3..days();

The double dot (..) is needed for integer numbers, else the interpreter thinks it's a mistyped float number. Another possible syntax that is just a bit longer but less confusing is:

var expire = new Date() + (3).days();

Pick the one you prefer.

##TODO

  • Add a getter version that only works on modern browsers

About

Number class methods to convert numbers to time

Resources

License

Stars

Watchers

Forks

Packages

No packages published