Skip to content

Commit 321d5d7

Browse files
committed
refactor: ♻️ Rename getDayOfWeekCode to getDayOfMonthCode for clarity
- Function name updated to reflect day-of-month behaviour - Removed the unused locale argument - Documentation updated to describe ddd formatting - No functional changes
1 parent 548a1f3 commit 321d5d7

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

src/date_utils.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -583,14 +583,14 @@ export function getWeek(date: Date): number {
583583
}
584584

585585
/**
586-
* Gets the day of the week code for a given day.
586+
* Gets the day-of-the-month code for a given date.
587+
* Returns a zero-padded 3-digit string from "001" to "031".
587588
*
588589
* @param day - The day.
589-
* @param locale - The locale.
590-
* @returns - The day of the week code.
590+
* @returns - A string representing the day of the month (e.g. "001", "002", "003", etc).
591591
*/
592-
export function getDayOfWeekCode(day: Date, locale?: Locale): string {
593-
return formatDate(day, "ddd", locale);
592+
export function getDayOfMonthCode(day: Date): string {
593+
return formatDate(day, "ddd");
594594
}
595595

596596
// *** Start of ***

src/day.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import {
1313
isEqual,
1414
isBefore,
1515
isAfter,
16-
getDayOfWeekCode,
16+
getDayOfMonthCode,
1717
getStartOfWeek,
1818
formatDate,
1919
type DateFilterOptionsWithDisabled,
@@ -445,7 +445,7 @@ export default class Day extends Component<DayProps> {
445445
return clsx(
446446
"react-datepicker__day",
447447
dayClassName,
448-
"react-datepicker__day--" + getDayOfWeekCode(this.props.day),
448+
"react-datepicker__day--" + getDayOfMonthCode(this.props.day),
449449
{
450450
"react-datepicker__day--disabled": this.isDisabled(),
451451
"react-datepicker__day--excluded": this.isExcluded(),

src/test/day_test.test.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { es } from "date-fns/locale";
33
import React from "react";
44

55
import {
6-
getDayOfWeekCode,
6+
getDayOfMonthCode,
77
newDate,
88
getDate,
99
addDays,
@@ -41,7 +41,7 @@ describe("Day", () => {
4141
it("should apply the day of week class", () => {
4242
let day = newDate();
4343
for (let i = 0; i < 7; i++) {
44-
const className = "react-datepicker__day--" + getDayOfWeekCode(day);
44+
const className = "react-datepicker__day--" + getDayOfMonthCode(day);
4545
const container = renderDay(day);
4646
expect(
4747
container

0 commit comments

Comments
 (0)