Skip to content

Commit 1a23ce3

Browse files
committed
small fix
1 parent 6cf6b5c commit 1a23ce3

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

packages/ui/src/components/Datepicker/Datepicker.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -203,10 +203,10 @@ const DatepickerRender: ForwardRefRenderFunction<DatepickerRef, DatepickerProps>
203203
case Views.Years:
204204
return `${startOfYearPeriod(viewDate, 10)} - ${startOfYearPeriod(viewDate, 10) + 9}`;
205205
case Views.Months:
206-
return getFormattedDate(language, viewDate, inputFormat, { year: "numeric" });
206+
return getFormattedDate(language, viewDate, { year: "numeric" });
207207
case Views.Days:
208208
default:
209-
return getFormattedDate(language, viewDate, inputFormat, { month: "long", year: "numeric" });
209+
return getFormattedDate(language, viewDate, { month: "long", year: "numeric" });
210210
}
211211
};
212212

@@ -274,7 +274,7 @@ const DatepickerRender: ForwardRefRenderFunction<DatepickerRef, DatepickerProps>
274274
}
275275
setIsOpen(true);
276276
}}
277-
value={selectedDate && getFormattedDate(language, selectedDate, inputFormat, {})}
277+
value={selectedDate && getFormattedDate(language, selectedDate, {}, inputFormat)}
278278
readOnly
279279
{...props}
280280
/>

packages/ui/src/components/Datepicker/helpers.spec.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,20 +154,20 @@ describe("addYears", () => {
154154
describe("getFormattedDate", () => {
155155
it("returns the formatted date string using the default options", () => {
156156
const date = new Date(2023, 0, 15); // January 15th, 2023
157-
const formattedDate = getFormattedDate("en", date, 'MMMM dd, yyyy');
157+
const formattedDate = getFormattedDate("en", date, {}, 'MMMM dd, yyyy');
158158
expect(formattedDate).toBe("January 15, 2023");
159159
});
160160

161161
it("returns the formatted date string using the specified options", () => {
162162
const date = new Date(2023, 0, 15); // January 15th, 2023
163163
const options: Intl.DateTimeFormatOptions = { month: "short", year: "numeric" };
164-
const formattedDate = getFormattedDate("en", date, 'MMM yyyy', options);
164+
const formattedDate = getFormattedDate("en", date, options, 'MMM yyyy');
165165
expect(formattedDate).toBe("Jan 2023");
166166
});
167167

168168
it("returns the formatted date string using the specified language", () => {
169169
const date = new Date(2023, 0, 15); // January 15th, 2023
170-
const formattedDate = getFormattedDate("pt-BR", date, 'dd-MMM-yyyy');
170+
const formattedDate = getFormattedDate("pt-BR", date);
171171
expect(formattedDate).toBe("15 de janeiro de 2023");
172172
});
173173
});

packages/ui/src/components/Datepicker/helpers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ export const addYears = (date: Date, amount: number): Date => {
101101
return newDate;
102102
};
103103

104-
export const getFormattedDate = (language: string, date: Date, dateFormat: string, options?: Intl.DateTimeFormatOptions,): string => {
104+
export const getFormattedDate = (language: string, date: Date, options?: Intl.DateTimeFormatOptions, dateFormat: string = 'dd-MMM-yyyy'): string => {
105105
let defaultOptions: Intl.DateTimeFormatOptions = {
106106
day: "numeric",
107107
month: "long",

0 commit comments

Comments
 (0)