fix: handle BC null-date sentinel on project header dates#200
Merged
Conversation
The project header used a local formatDate that wrapped `new Date(...).toLocaleDateString('en-GB', ...)`. BC returns "0001-01-01" as the
null-date sentinel for projects with no start/end set. The empty-string
guard didn't catch it, so toLocaleDateString rendered the value as
"31 Dec 1" (timezone shift in negative-UTC zones flips the day).
- Add a sentinel guard for any "0001-..." date string.
- Use the shared formatDate util + DATE_FORMAT_FULL ("d MMM yyyy"), which
goes through date-fns parseISO and avoids the timezone shift.
Fixes #199
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes incorrect project header date rendering when Business Central returns its null-date sentinel (0001-01-01), which previously could display as 31 Dec 1 due to new Date(...) timezone shifting.
Changes:
- Adds a guard to treat
0001-...date strings as “Unspecified” in the project header. - Switches header date rendering to the shared
formatDateutil withDATE_FORMAT_FULLto avoid timezone-shifted display for real dates.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Per Copilot review on PR #200 — describe the actual "31 Dec 1" output (timezone-shifted day + unpadded year) rather than the abstract "year-1 garbage date" framing, which made the symptom less obvious to readers. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
BenGWeeks
approved these changes
May 5, 2026
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.
Summary
Project details header was showing
Start: 31 Dec 1/End: 31 Dec 1for every project with no start/end set in Business Central.Cause: BC returns
0001-01-01as its null-date sentinel. The localformatDateinProjectHeader.tsxonly guarded against empty strings, so the sentinel reachednew Date(...).toLocaleDateString('en-GB', ...)and was rendered literally — with a timezone shift in negative-UTC zones flipping it to "31 Dec 1".0001-...date string (returnsUnspecified).formatDateutil +DATE_FORMAT_FULL(d MMM yyyy), which uses date-fnsparseISOand avoids the timezone shift on real dates too.Codebase already recognises
0001-01-01as a sentinel inprojectDetailsService.ts:507for plan-line dates — this brings the project header in line with that convention.Test plan
Start: Unspecified/End: Unspecified.d MMM yyyy(e.g.31 Dec 2025).Fixes #199
🤖 Generated with Claude Code