Skip to content

Commit

Permalink
$show.[data.json].ts
Browse files Browse the repository at this point in the history
  • Loading branch information
stephenwade committed Feb 23, 2025
1 parent 7776376 commit 7632827
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions app/routes/$show.[data.json].ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { json, type LoaderFunction } from '@remix-run/node';
import { addSeconds, formatISO } from 'date-fns';
import { Temporal } from 'temporal-polyfill';

import { db } from '~/db.server/db';
import type { ShowData } from '~/types/ShowData';
Expand Down Expand Up @@ -28,10 +28,16 @@ export const loader = (async ({ params }) => {
id: set.id,
audioUrl: set.audioFile.url,
artist: set.artist,
start: addSeconds(show.startDate, set.offset).toISOString(),
start: Temporal.Instant.from(show.startDate)
.add({
// `.add()` requires integers
// seconds: set.offset,
milliseconds: Math.round(set.offset * 1000),
})
.toString(),
duration: set.audioFile.duration,
})),
serverDate: formatISO(new Date()),
serverDate: Temporal.Now.instant().toString(),
};

// Single Fetch doesn't work with Clerk
Expand Down

0 comments on commit 7632827

Please sign in to comment.