fix: activity history group headers render as "Invalid date" - #167
Open
everysingletear wants to merge 1 commit into
Open
fix: activity history group headers render as "Invalid date"#167everysingletear wants to merge 1 commit into
everysingletear wants to merge 1 commit into
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
In the activity timeline (
UserActivities), every group header renders as "Invalid date" for most locales.groupByDatebuilds its grouping key withtoLocaleDateString():and the timeline then renders that same key back through the localized formatter:
fmt.datehands 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 literalInvalid datewhere 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-USdev machine.Fix
Key the groups on a stable local ISO day (
YYYY-MM-DD) — a formatfmt.dateparses reliably — instead of a display string. Records with no usable timestamp go into anunknownbucket rendered as an em dash, so a missingperformedAt/updatedAtno longer producesInvalid dateeither.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