23 lines
550 B
TypeScript
23 lines
550 B
TypeScript
|
|||
|
|
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;
|
||
|
|
}
|