Skip to content

Commit a1a7531

Browse files
committed
When coercing realtime date strings, make sure they are set to UTC
1 parent 7cfecf9 commit a1a7531

File tree

2 files changed

+22
-7
lines changed

2 files changed

+22
-7
lines changed

.changeset/silent-trees-jump.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@trigger.dev/core": patch
3+
---
4+
5+
Fix issue with dates in realtime not reflecting the current timezone

packages/core/src/v3/schemas/api.ts

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -682,16 +682,26 @@ export const UpdateMetadataResponseBody = z.object({
682682

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

685+
const RawShapeDate = z
686+
.string()
687+
.transform((val) => `${val}Z`)
688+
.pipe(z.coerce.date());
689+
690+
const RawOptionalShapeDate = z
691+
.string()
692+
.nullish()
693+
.transform((val) => (val ? new Date(`${val}Z`) : val));
694+
685695
export const SubscribeRunRawShape = z.object({
686696
id: z.string(),
687697
idempotencyKey: z.string().nullish(),
688-
createdAt: z.coerce.date(),
689-
updatedAt: z.coerce.date(),
690-
startedAt: z.coerce.date().nullish(),
691-
delayUntil: z.coerce.date().nullish(),
692-
queuedAt: z.coerce.date().nullish(),
693-
expiredAt: z.coerce.date().nullish(),
694-
completedAt: z.coerce.date().nullish(),
698+
createdAt: RawShapeDate,
699+
updatedAt: RawShapeDate,
700+
startedAt: RawOptionalShapeDate,
701+
delayUntil: RawOptionalShapeDate,
702+
queuedAt: RawOptionalShapeDate,
703+
expiredAt: RawOptionalShapeDate,
704+
completedAt: RawOptionalShapeDate,
695705
taskIdentifier: z.string(),
696706
friendlyId: z.string(),
697707
number: z.number(),

0 commit comments

Comments
 (0)