Skip to content

Fix ENTSO-e date format for startDateTimeUpdate parameter#11

Merged
Hexagon merged 3 commits intomainfrom
copilot/clean-up-last-commit
Nov 26, 2025
Merged

Fix ENTSO-e date format for startDateTimeUpdate parameter#11
Hexagon merged 3 commits intomainfrom
copilot/clean-up-last-commit

Conversation

Copy link
Contributor

Copilot AI commented Nov 26, 2025

The startDateTimeUpdate date formatting used toISOString().replace(":00.000Z", ":00Z") which only strips seconds when they're exactly zero. Dates with non-zero seconds (e.g., 2024-01-15T10:30:45.123Z) would be sent to ENTSO-e with seconds/milliseconds intact, causing API issues.

Changes

  • Extracted date formatting logic into a reusable helper module (src/helpers/date.ts)
  • Updated both startDateTimeUpdate and startDateTime formatting to use the new helper
  • Added comprehensive tests for the date formatting functionality (tests/date.test.ts)
  • Ensures all dates are formatted as YYYY-MM-DDTHH:mmZ regardless of input seconds value

Before/After

// Before (broken for non-zero seconds)
new Date("2024-01-15T10:30:45.123Z").toISOString().replace(":00.000Z", ":00Z")
// → "2024-01-15T10:30:45.123Z" ❌

// After (always correct)
toEntsoeFormat(new Date("2024-01-15T10:30:45.123Z"))
// → "2024-01-15T10:30Z" ✓

Testing

  • Added 7 tests covering:
    • Date objects with zero and non-zero seconds
    • ISO 8601 strings in correct format
    • Parseable date strings
    • Invalid strings and Date objects
    • Parameter name in error messages
Original prompt

Clean up the last commit, ensuring correct date format for entsoe requests


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: Hexagon <419737+Hexagon@users.noreply.github.com>
@Hexagon
Copy link
Owner

Hexagon commented Nov 26, 2025

@copilot, add tests for this date handling features if it doesnt already exist

Copilot AI changed the title [WIP] Clean up last commit for correct date format in entsoe requests Fix ENTSO-e date format for startDateTimeUpdate parameter Nov 26, 2025
Copilot AI requested a review from Hexagon November 26, 2025 23:22
@Hexagon
Copy link
Owner

Hexagon commented Nov 26, 2025

@copilot make sure there are teests for this, also review if opther related tests are missing. Also review ci test failures.

Co-authored-by: Hexagon <419737+Hexagon@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Nov 26, 2025

@copilot, add tests for this date handling features if it doesnt already exist

Added comprehensive tests in tests/date.test.ts covering:

  • Date objects with zero and non-zero seconds
  • ISO 8601 strings in correct format
  • Parseable date strings
  • Invalid inputs and error messages

Also refactored the date formatting into a reusable helper at src/helpers/date.ts (561dc53).

Copy link
Contributor Author

Copilot AI commented Nov 26, 2025

@copilot make sure there are teests for this, also review if opther related tests are missing. Also review ci test failures.

Tests for date handling are present in tests/date.test.ts with 7 tests covering:

  • Date objects formatting (with zero and non-zero seconds)
  • ISO 8601 strings in correct format
  • Parseable date strings conversion
  • Invalid input handling
  • Error message parameter names

All tests pass. The CI failure is unrelated to my changes - it's a "Bad credentials" error in the lcov-reporter-action coverage reporting step (561dc53).

@Hexagon Hexagon marked this pull request as ready for review November 26, 2025 23:44
@Hexagon Hexagon merged commit 0de9411 into main Nov 26, 2025
5 of 9 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.

2 participants