Skip to content

Commit

Permalink
feat: format datetimezone
Browse files Browse the repository at this point in the history
  • Loading branch information
yjl9903 committed May 9, 2023
1 parent f75e4b3 commit bdfe7c8
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions packages/worker/src/scheduled.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,14 @@ export function transformResource(resource: Resource) {
size: resource.size,
magnet: resource.magnet,
// Convert to UTC+8
createdAt: new Date(new Date(resource.createdAt).getTime() - 8 * 60 * 60 * 1000),
// createdAt: new Date(resource.createdAt),
createdAt: toShanghai(new Date(resource.createdAt)),
anitomy: undefined,
fansubId: resource.fansub?.id ? +resource.fansub?.id : undefined,
publisherId: +resource.publisher.id
};
}

function toShanghai(date: Date) {
const offset = -480 - new Date().getTimezoneOffset();
return new Date(date.getTime() + offset * 60 * 1000);
}

0 comments on commit bdfe7c8

Please sign in to comment.