Skip to content

fix: handle BC null-date sentinel on project header dates#200

Merged
EdiWeeks merged 2 commits into
mainfrom
fix/199-project-header-sentinel-date
May 5, 2026
Merged

fix: handle BC null-date sentinel on project header dates#200
EdiWeeks merged 2 commits into
mainfrom
fix/199-project-header-sentinel-date

Conversation

@EdiWeeks
Copy link
Copy Markdown
Contributor

@EdiWeeks EdiWeeks commented May 5, 2026

Summary

Project details header was showing Start: 31 Dec 1 / End: 31 Dec 1 for every project with no start/end set in Business Central.

Cause: BC returns 0001-01-01 as its null-date sentinel. The local formatDate in ProjectHeader.tsx only guarded against empty strings, so the sentinel reached new Date(...).toLocaleDateString('en-GB', ...) and was rendered literally — with a timezone shift in negative-UTC zones flipping it to "31 Dec 1".

  • Add a sentinel guard for any 0001-... date string (returns Unspecified).
  • Replace the bespoke local helper with the shared formatDate util + DATE_FORMAT_FULL (d MMM yyyy), which uses date-fns parseISO and avoids the timezone shift on real dates too.

Codebase already recognises 0001-01-01 as a sentinel in projectDetailsService.ts:507 for plan-line dates — this brings the project header in line with that convention.

image

Test plan

  • Open a project that has no start/end set in BC (e.g. PR00080) → header shows Start: Unspecified / End: Unspecified.
  • Open a project that has real start/end dates → both render as d MMM yyyy (e.g. 31 Dec 2025).
  • Cross-check on a UTC-negative timezone (the original symptom) — real dates do not shift by a day.

Fixes #199

🤖 Generated with Claude Code

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>
Copilot AI review requested due to automatic review settings May 5, 2026 11:41
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 formatDate util with DATE_FORMAT_FULL to avoid timezone-shifted display for real dates.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/components/projects/ProjectHeader.tsx Outdated
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>
@EdiWeeks EdiWeeks requested a review from BenGWeeks May 5, 2026 11:47
@EdiWeeks EdiWeeks merged commit 1dacc01 into main May 5, 2026
4 checks passed
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.

Project details page shows malformed Start/End dates ('31 Dec 1') for all projects

3 participants