Skip to content

Fix Invalid Date for API-created history records#559

Open
scowalt wants to merge 1 commit into
astashov:masterfrom
scowalt:fix/history-date-iso-format
Open

Fix Invalid Date for API-created history records#559
scowalt wants to merge 1 commit into
astashov:masterfrom
scowalt:fix/history-date-iso-format

Conversation

@scowalt

@scowalt scowalt commented Apr 15, 2026

Copy link
Copy Markdown

Summary

History records created via the MCP API (create_history_record / update_history_record) display "Invalid Date" on iOS Safari/WebKit.

Root cause: The date field in LiftohistoryDeserializer stores the raw Liftohistory text format:

"2026-02-28 10:45:30 +00:00"  (space separator)

iOS Safari's Date.parse() requires strict ISO 8601 with the T separator and returns NaN for space-separated date strings, causing "Invalid Date" in the UI.

Fix: Use parsedDate.toISOString() (which is already a correctly parsed Date object on line 138) to store:

"2026-02-28T10:45:30.000Z"  (strict ISO 8601)

This matches what the app stores when creating records through the normal UI flow (Program.createHistory, Progress.changeDate).

Reproduction

  1. Create a history record via the MCP API:
    2026-03-29T01:37:57Z / duration: 1800s / exercises: {
      Bench Press / 3x8 185lb
    }
    
  2. View the record in the Liftosaur iOS app
  3. The workout date displays as "Invalid Date"

Change

One-line change in src/liftohistory/liftohistoryDeserializer.ts:

-    date: dateStr,
+    date: parsedDate.toISOString(),

Records created via create_history_record or update_history_record
show "Invalid Date" on iOS Safari/WebKit because the `date` field
stores the raw Liftohistory text format ("2026-02-28 10:45:30 +00:00"
with space separator). Safari's Date.parse() requires strict ISO 8601
with the T separator and returns NaN for space-separated dates.

Use parsedDate.toISOString() to store "2026-02-28T10:45:30.000Z"
instead, matching what the app itself stores when creating records
through the normal UI flow (e.g. Program.createHistory, Progress.changeDate).
@scowalt

scowalt commented Apr 15, 2026

Copy link
Copy Markdown
Author

I generated this with Claude Code but it reflects a real issue I've been having, lmk if you have concerns or if anything is unclear

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant