Skip to content

Commit

Permalink
Allow same-day rules
Browse files Browse the repository at this point in the history
  • Loading branch information
GAsplund committed Jan 5, 2024
1 parent cb1cfcd commit 6af6741
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion backend/src/services/rule.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,10 @@ export const checkRules = async (prisma: PrismaClient, event: Event) => {
};

const validDate = (start: Date, end: Date): boolean => {
return start.getTime() > 0 && end.getTime() > 0 && start <= end;
};

const validDateTime = (start: Date, end: Date): boolean => {
return start.getTime() > 0 && end.getTime() > 0 && start < end;
};

Expand Down Expand Up @@ -213,7 +217,7 @@ export const createRule = async (

const start_time = new Date(rule.start_date + "T" + rule.start_time);
const end_time = new Date(rule.start_date + "T" + rule.end_time);
if (!validDate(start_time, end_time)) {
if (!validDateTime(start_time, end_time)) {
return {
sv: "Ogiltig tid",
en: "Invalid time",
Expand Down

0 comments on commit 6af6741

Please sign in to comment.