feat: migrate utils
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
|
||||
export const DEFAULT_COLOR: string = '#536dfe';
|
||||
|
||||
export function gcd(a: number, b: number): number {
|
||||
if (b == 0) return a;
|
||||
return gcd(b, a % b);
|
||||
}
|
||||
|
||||
export function lcm(a: number, b: number): number {
|
||||
return a / gcd(a, b) * b;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Monday-first the day of week from given date instead of Sunday-first.
|
||||
* @param date The date for getting weekday.
|
||||
* @returns The zero-based weekday. 0 stands for Monday.
|
||||
*/
|
||||
export function getWeekday(date: Date): number {
|
||||
let day = date.getDay();
|
||||
if (day == 0) return 6;
|
||||
else return day - 1;
|
||||
}
|
||||
Reference in New Issue
Block a user