Skip to content

Commit 33c82c3

Browse files
fix separator
1 parent 5743f0c commit 33c82c3

File tree

3 files changed

+13
-13
lines changed

3 files changed

+13
-13
lines changed

src/pages/schedule/ScheduleClassTable/ScheduleClass.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import {
1212
} from "@mui/material";
1313

1414
import { ScheduleClassTableRowDay } from "./ScheduleClassTableRowDay";
15-
import { DateWithWeekDay, DayOfTheWeek, ScheduleDay } from "../types";
15+
import { ScheduleDay } from "../types";
1616
import { tableHeadItemStyle, tableHeadStyle } from "../../styles";
1717
import { getSchedulesForAListOfDays } from "../requests";
1818
import { dateWithWeekDayForNext7Days } from "../../../utils/date";

src/utils/date.test.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -134,13 +134,13 @@ describe('Date Utility Functions', () => {
134134

135135
it('should return correct dates for next 7 days', () => {
136136
const result = dateWithWeekDayForNext7Days();
137-
expect(result[0].date).toBe('20240115'); // 2024-01-15
138-
expect(result[1].date).toBe('20240116'); // 2024-01-16
139-
expect(result[2].date).toBe('20240117'); // 2024-01-17
140-
expect(result[3].date).toBe('20240118'); // 2024-01-18
141-
expect(result[4].date).toBe('20240119'); // 2024-01-19
142-
expect(result[5].date).toBe('20240120'); // 2024-01-20
143-
expect(result[6].date).toBe('20240121'); // 2024-01-21
137+
expect(result[0].date).toBe('2024-01-15'); // 2024-01-15
138+
expect(result[1].date).toBe('2024-01-16'); // 2024-01-16
139+
expect(result[2].date).toBe('2024-01-17'); // 2024-01-17
140+
expect(result[3].date).toBe('2024-01-18'); // 2024-01-18
141+
expect(result[4].date).toBe('2024-01-19'); // 2024-01-19
142+
expect(result[5].date).toBe('2024-01-20'); // 2024-01-20
143+
expect(result[6].date).toBe('2024-01-21'); // 2024-01-21
144144
});
145145

146146
it('should handle month boundary correctly', () => {

src/utils/date.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ export function getWeekDay(date: Date): DayOfTheWeek {
1414
}
1515

1616
export function getCurrentDate(date: Date, separator = ""): string {
17-
let day = date.getDate();
18-
let month = date.getMonth() + 1;
19-
let year = date.getFullYear();
17+
const day = date.getDate();
18+
const month = date.getMonth() + 1;
19+
const year = date.getFullYear();
2020

2121
return `${year}${separator}${
2222
month < 10 ? `0${month}` : `${month}`
@@ -26,13 +26,13 @@ export function getCurrentDate(date: Date, separator = ""): string {
2626
export function dateWithWeekDayForNext7Days(): DateWithWeekDay[] {
2727
const dates = [];
2828
const currentDate = new Date();
29-
for (let i = 0; i < 7; i++) {
29+
for (let i = 0; i < 7; i += 1) {
3030
const date = new Date(currentDate);
3131
date.setDate(currentDate.getDate() + i);
3232

3333
dates.push({
3434
week_day: getWeekDay(date),
35-
date: getCurrentDate(date)
35+
date: getCurrentDate(date, "-")
3636
} as DateWithWeekDay);
3737
}
3838
return dates;

0 commit comments

Comments
 (0)