Skip to content

Commit

Permalink
R2-2618 Date format in Insights should match format used in rest of app
Browse files Browse the repository at this point in the history
  • Loading branch information
aespinoza-quoin committed Oct 23, 2023
1 parent 3bd87e6 commit 45e8153
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export default (groupId, groupedBy, localizeDate) => {
case MONTH: {
const [year, groupKey] = groupId.split("-");

return `${year}-${groupTranslator(groupKey, localizeDate)}`;
return `${groupTranslator(groupKey, localizeDate)}-${year}`;
}
case WEEK: {
const [start, end] = groupId.split(" - ");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,20 @@ describe("translateGroupId", () => {
it("translates group of months", () => {
const result = translateGroupId("2023-03", MONTH, format);

expect(result).to.equals("2023-Mar");
expect(result).to.equals("Mar-2023");
});

it("translates group of quarters", () => {
const result = translateGroupId("2023-Q1", QUARTER, format);

expect(result).to.equals("2023-Q1");
expect(result).to.equals("Q1-2023");
});

it("translates group of weeks", () => {
const localizeDate = (value, dateFormat) => format(parseISO(value), dateFormat);

const result = translateGroupId("2023-01-01 - 2023-01-07", WEEK, localizeDate);

expect(result).to.equals("2023-Jan-01 - 2023-Jan-07");
expect(result).to.equals("01-Jan-2023 - 07-Jan-2023");
});
});
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export default (startDate, endDate, localizeDate) => {
return `${localizeDate(startDate, "yyyy-MMM-dd")} - ${localizeDate(endDate, "yyyy-MMM-dd")}`;
return `${localizeDate(startDate, "dd-MMM-yyyy")} - ${localizeDate(endDate, "dd-MMM-yyyy")}`;
};
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ describe("translateWeek", () => {
const localizeDate = (value, dateFormat) => format(parseISO(value), dateFormat);
const result = translateWeek("2020-06-07", "2020-06-13", localizeDate);

expect(result).to.equal("2020-Jun-07 - 2020-Jun-13");
expect(result).to.equal("07-Jun-2020 - 13-Jun-2020");
});
});

0 comments on commit 45e8153

Please sign in to comment.