Skip to content

Commit

Permalink
fix(outputs-ui): correct weekly data formatting to support 53-week years
Browse files Browse the repository at this point in the history
(cherry picked from commit 70bd975)
  • Loading branch information
hdinia authored and skamril committed Apr 19, 2024
1 parent b42843a commit 3f6302d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ v2.16.8 (2024-04-19)
* **variants:** avoid recursive error when creating big variant tree [`#1967`](https://github.com/AntaresSimulatorTeam/AntaREST/pull/1967)
* **outputs:** build outputs config even when using cache [`#1958`](https://github.com/AntaresSimulatorTeam/AntaREST/pull/1958)
* **comments:** use a command to update comments on a variant [`#1959`](https://github.com/AntaresSimulatorTeam/AntaREST/pull/1959)
* **outputs (ui):** correct weekly data formatting to support 53-week years [`#1975`](https://github.com/AntaresSimulatorTeam/AntaREST/pull/1975)


v2.16.7 (2024-03-05)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,19 +158,23 @@ function ResultDetails() {
return ["Annual"];
}

// Directly use API's week index (handles 53 weeks) as no formatting is required.
// !NOTE: Suboptimal: Assumes API consistency, lacks flexibility.
if (timestep === Timestep.Weekly) {
return matrixRes.data.index.map((weekNumber) => weekNumber.toString());
}

// Original date/time format mapping for moment parsing
const parseFormat = {
[Timestep.Hourly]: "MM/DD HH:mm",
[Timestep.Daily]: "MM/DD",
[Timestep.Weekly]: "WW",
[Timestep.Monthly]: "MM",
}[timestep];

// Output formats for each timestep to match legacy UI requirements
const outputFormat = {
[Timestep.Hourly]: "DD MMM HH:mm I",
[Timestep.Daily]: "DD MMM I",
[Timestep.Weekly]: "WW",
[Timestep.Monthly]: "MMM",
}[timestep];

Expand Down

0 comments on commit 3f6302d

Please sign in to comment.