add support for opening hours that automatically change over time

This commit is contained in:
2024-07-08 02:42:02 +02:00
parent ada7d25083
commit 355887518b
23 changed files with 834 additions and 18 deletions
+3 -8
View File
@@ -1,5 +1,4 @@
import {
compareAsc,
endOfWeek,
startOfToday,
startOfWeek,
@@ -8,10 +7,10 @@ import {
addWeeks,
parseISO,
} from "date-fns";
import { toLocalTime, formatDate } from "./date";
import { toLocalTime, formatDate, compareDates } from "./date";
import { graphql } from "@/gql";
import { EventFragment, EventCategory, EventOccurrence } from "@/gql/graphql";
import { PIG_NAMES, PigName, randomElement } from "@/lib/common";
import { EventFragment, EventOccurrence } from "@/gql/graphql";
import { PIG_NAMES, randomElement } from "@/lib/common";
export type {
EventFragment,
@@ -134,10 +133,6 @@ export function getSingularEvents(events: EventFragment[]): SingularEvent[] {
.flat();
}
export function compareDates(a: Date | string, b: Date | string) {
return compareAsc(new Date(a), new Date(b));
}
export function sortSingularEvents(events: SingularEvent[]) {
return events.sort((a, b) =>
compareDates(a.occurrence.start, b.occurrence.start)