Skip to content

nishemon/TimeUnit4js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TimeUnit4js

TimeUnit4js is "another" porting of Java TimeUnit that is based on JSR-166.

If you want Java TimeUnit in JavaScript, you should use TimeUnit js. It has more compatibility with Java TimeUnit and is stable.

TimeUnit4js is under development.

Basic

var msec = TimeUnit.HOURS.toMillis(3);
// msec === 3 * 60 * 60 * 1000
var msec2 = TimeUnit.MILLISECONDS.from(3, TimeUnit.HOURS);
// msec2 === 3 * 60 * 60 * 1000

There are MILLISECONDS(toMillis), SECONDS(toSeconds), MINUTES(toMinutes), HOURS(toHours), DAYS(toDays) and WEEKS(toWeeks).

Unlike original, TimeUnit.NANOSECONDS, TimeUnit.MICROSECONDS, "toMicros" and "toNanos" are not implemented. I have never used and seen, yet.

Extend

setTimeout and setInterval with TimeUnit

TimeUnit.MINUTE.setTimeout(10, function() {
    console.log('after 10 minutes');
}

Manipulate Date

var dayAfterTommorow = TimeUnit.HOUR.plus(new Date, 48);

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published