Skip to content

Commit

Permalink
When coercing realtime date strings, make sure they are set to UTC
Browse files Browse the repository at this point in the history
  • Loading branch information
ericallam committed Jan 7, 2025
1 parent 7cfecf9 commit a1a7531
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 7 deletions.
5 changes: 5 additions & 0 deletions .changeset/silent-trees-jump.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@trigger.dev/core": patch
---

Fix issue with dates in realtime not reflecting the current timezone
24 changes: 17 additions & 7 deletions packages/core/src/v3/schemas/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -682,16 +682,26 @@ export const UpdateMetadataResponseBody = z.object({

export type UpdateMetadataResponseBody = z.infer<typeof UpdateMetadataResponseBody>;

const RawShapeDate = z
.string()
.transform((val) => `${val}Z`)
.pipe(z.coerce.date());

const RawOptionalShapeDate = z
.string()
.nullish()
.transform((val) => (val ? new Date(`${val}Z`) : val));

export const SubscribeRunRawShape = z.object({
id: z.string(),
idempotencyKey: z.string().nullish(),
createdAt: z.coerce.date(),
updatedAt: z.coerce.date(),
startedAt: z.coerce.date().nullish(),
delayUntil: z.coerce.date().nullish(),
queuedAt: z.coerce.date().nullish(),
expiredAt: z.coerce.date().nullish(),
completedAt: z.coerce.date().nullish(),
createdAt: RawShapeDate,
updatedAt: RawShapeDate,
startedAt: RawOptionalShapeDate,
delayUntil: RawOptionalShapeDate,
queuedAt: RawOptionalShapeDate,
expiredAt: RawOptionalShapeDate,
completedAt: RawOptionalShapeDate,
taskIdentifier: z.string(),
friendlyId: z.string(),
number: z.number(),
Expand Down

0 comments on commit a1a7531

Please sign in to comment.