Skip to content

Instantly share code, notes, and snippets.

@InventivetalentDev
Created December 30, 2020 21:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save InventivetalentDev/5a9311fd3b86946d22564aec045539cc to your computer and use it in GitHub Desktop.
Save InventivetalentDev/5a9311fd3b86946d22564aec045539cc to your computer and use it in GitHub Desktop.
/**
* Time utility class
*/
export class Time {
static millis(m: number) {
return m;
}
/**
* Convert seconds to milliseconds
*/
static seconds(s: number) {
return this.millis(s * 1000);
}
/**
* Convert minutes to milliseconds
*/
static minutes(m: number) {
return this.seconds(m * 60);
}
/**
* Convert hours to milliseconds
*/
static hours(h: number) {
return this.minutes(h * 60);
}
/**
* Get the current time in milliseconds
*/
static get now(): number {
return Date.now();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment