feat: migrate utils

This commit is contained in:
2026-06-30 15:41:34 +08:00
parent fda2fe9ec9
commit fcc022d070
2 changed files with 37 additions and 3 deletions
+22
View File
@@ -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;
}