util.ts
698 Bytes
export class Util {
static getISODate() : string {
return (new Date()).toISOString().slice(0,10);
}
static getDateInMinutes() : number {
let now = new Date();
return (now.getHours() * 60) + now.getMinutes();
}
/**
* convert a time input to minutes
* e.g. 23:59 = 1439
*/
static convertToMinutes(time:string) : number {
let times = time.split(":");
let convered = (parseInt(times[0]) * 60) + parseInt(times[1]);
return (convered >= 0 && convered <= 1439) ? convered : 0;
}
static calculateNextMinute() : number {
return (60 - (Math.round((new Date()).getTime() / 1000) % 60)) * 1000;
}
}