Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/date_utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -583,14 +583,14 @@ export function getWeek(date: Date): number {
}

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

// *** Start of ***
Expand Down
4 changes: 2 additions & 2 deletions src/day.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
isEqual,
isBefore,
isAfter,
getDayOfWeekCode,
getDayOfMonthCode,
getStartOfWeek,
formatDate,
type DateFilterOptionsWithDisabled,
Expand Down Expand Up @@ -445,7 +445,7 @@ export default class Day extends Component<DayProps> {
return clsx(
"react-datepicker__day",
dayClassName,
"react-datepicker__day--" + getDayOfWeekCode(this.props.day),
"react-datepicker__day--" + getDayOfMonthCode(this.props.day),
{
"react-datepicker__day--disabled": this.isDisabled(),
"react-datepicker__day--excluded": this.isExcluded(),
Expand Down
6 changes: 3 additions & 3 deletions src/test/day_test.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { es } from "date-fns/locale";
import React from "react";

import {
getDayOfWeekCode,
getDayOfMonthCode,
newDate,
getDate,
addDays,
Expand Down Expand Up @@ -38,10 +38,10 @@ describe("Day", () => {
expect(container.textContent).toBe(getDate(day) + "");
});

it("should apply the day of week class", () => {
it("should apply the day of month class", () => {
let day = newDate();
for (let i = 0; i < 7; i++) {
const className = "react-datepicker__day--" + getDayOfWeekCode(day);
const className = `react-datepicker__day--${getDayOfMonthCode(day)}`;
const container = renderDay(day);
expect(
container
Expand Down
Loading