Skip to content

Commit

Permalink
Merge pull request #1975 from AntaresSimulatorTeam/bugfix/weekly-date…
Browse files Browse the repository at this point in the history
…-formatting

fix(ui-results): correct weekly data formatting to support 53-week years
  • Loading branch information
hdinia authored Mar 11, 2024
2 parents a4d647d + 70bd975 commit aeaf738
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -160,19 +160,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 aeaf738

Please sign in to comment.