feat: add logging
This commit is contained in:
@@ -113,6 +113,30 @@ function componentToHex(c: number) {
|
||||
return hex.length == 1 ? "0" + hex : hex;
|
||||
}
|
||||
|
||||
export function getTimeCacheKey() {
|
||||
const d = new Date();
|
||||
const year = d.getFullYear();
|
||||
const month = d.getMonth().toString().padStart(2, "0");
|
||||
const day = d.getDate().toString().padStart(2, "0");
|
||||
const hour = d.getHours().toString().padStart(2, "0");
|
||||
const minute = d.getMinutes().toString().padStart(2, "0");
|
||||
const seconds = d.getSeconds().toString().padStart(2, "0");
|
||||
return `${year}:${month}:${day}:${hour}:${minute}:${seconds}`;
|
||||
}
|
||||
|
||||
export function parseTimeCacheKey(key: string) {
|
||||
const [_year, _month, _day, _hour, _minute, _second] = key.split(":")
|
||||
.slice(1).map((s) => parseInt(s));
|
||||
const d = new Date();
|
||||
d.setFullYear(_year);
|
||||
d.setMonth(_month);
|
||||
d.setDate(_day);
|
||||
d.setHours(_hour);
|
||||
d.setMinutes(_minute);
|
||||
d.setSeconds(_second);
|
||||
return d;
|
||||
}
|
||||
|
||||
export function rgbToHex(r: number, g: number, b: number) {
|
||||
return "#" + componentToHex(r) + componentToHex(g) + componentToHex(b);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user