Fix Garmin sync to handle PocketBase date strings
All checks were successful
Deploy / deploy (push) Successful in 2m38s

PocketBase returns date fields as ISO strings, not Date objects.
The sync was failing with "e.getTime is not a function" because
the code expected Date objects.

- Export mapRecordToUser from pocketbase.ts
- Use mapRecordToUser in cron route to properly parse dates
- Add test for handling date fields as ISO strings

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-01-15 07:38:37 +00:00
parent 4ba9f44cef
commit 3a06bff4d4
3 changed files with 63 additions and 6 deletions

View File

@@ -88,7 +88,7 @@ function parseDate(value: unknown): Date | null {
/**
* Maps a PocketBase record to our typed User interface.
*/
function mapRecordToUser(record: RecordModel): User {
export function mapRecordToUser(record: RecordModel): User {
return {
id: record.id,
email: record.email as string,