Skip to content

fix: activity history group headers render as "Invalid date" - #167

Open
everysingletear wants to merge 1 commit into
donetick:developfrom
everysingletear:fix/activities-date-grouping
Open

fix: activity history group headers render as "Invalid date"#167
everysingletear wants to merge 1 commit into
donetick:developfrom
everysingletear:fix/activities-date-grouping

Conversation

@everysingletear

Copy link
Copy Markdown

Problem

In the activity timeline (UserActivities), every group header renders as "Invalid date" for most locales.

groupByDate builds its grouping key with toLocaleDateString():

const date = new Date(item.performedAt || item.updatedAt).toLocaleDateString()

and the timeline then renders that same key back through the localized formatter:

{fmt.date(date)}

fmt.date hands the string to moment, which cannot reparse a locale-formatted date — "16.07.2026", "2026/7/16", "16/07/2026" are all unparseable. The result is a literal Invalid date where the day heading should be.

It happens to look fine only where the locale format is close enough to a format moment guesses correctly, which is why it is easy to miss on an en-US dev machine.

Fix

Key the groups on a stable local ISO day (YYYY-MM-DD) — a format fmt.date parses reliably — instead of a display string. Records with no usable timestamp go into an unknown bucket rendered as an em dash, so a missing performedAt/updatedAt no longer produces Invalid date either.

Built the key from local date parts rather than toISOString() on purpose: toISOString() converts to UTC and would shift activity into the wrong day for anyone east or west of UTC around midnight.

Notes

  • Group ordering is unchanged. The keys are non-integer strings, so object insertion order is preserved exactly as before — groups still follow the order records arrive in.
  • No string/i18n changes; this is purely the grouping key.
  • Single file, 14 lines. Build is green.

groupByDate keyed each group on `new Date(...).toLocaleDateString()`, and
the timeline then rendered that key through `fmt.date(date)`. moment cannot
reparse a locale-formatted string, so every group header rendered as
"Invalid date" outside a narrow set of locales.

Key groups on a stable local ISO day (YYYY-MM-DD) instead, which fmt.date
parses correctly. Records with no usable timestamp fall into an "unknown"
bucket rendered as an em dash rather than crashing the formatter.

Group ordering is unchanged: keys are non-integer strings, so insertion
order is preserved exactly as before.
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