Slight reformatting with prettier

This commit is contained in:
Xevion
2023-02-27 19:53:46 -06:00
parent 8585be0849
commit db576298cb
2 changed files with 65 additions and 55 deletions

View File

@@ -45,9 +45,12 @@ const TimeConfigSchema = z.object({
return parsed;
}),
// The days this configuration is active on.
days: z.array(DayEnumSchema).nonempty().transform(arr => {
return new Set<DayEnum>(arr);
}),
days: z
.array(DayEnumSchema)
.nonempty()
.transform((arr) => {
return new Set<DayEnum>(arr);
}),
// If a notification isn't delivery within 10 minutes e.g. "00:30", 24 hour time
maxLate: z
.string()
@@ -211,11 +214,15 @@ const dayAsNumber: Record<string, DayEnum> = {
export async function getMatchingTime(
config: Configuration,
now = new Date()
now: Date = new Date()
): Promise<TimeConfig | null> {
const times = config.times.filter((time) => {
// If the day doesn't match, skip.
if (!time.days.has(dayAsNumber[now.getDay().toString()])) return false;
const nowTime = {
hours: now.getHours(),
minutes: now.getMinutes()
};
const startTime = time.time;
const endTime = addTime(
@@ -223,8 +230,6 @@ export async function getMatchingTime(
time.maxLate ?? { hours: 0, minutes: 0 }
);
const nowTime = { hours: now.getHours(), minutes: now.getMinutes() };
return (
compareTime(nowTime, startTime) >= 0 && compareTime(nowTime, endTime) <= 0
);