Skip to content

Commit 35edfa5

Browse files
committed
Fix: Update types on getFormattedDate function
1 parent 5974cf6 commit 35edfa5

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/Components/DatePickerProvider.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ interface IDatePickerContext {
1515
setShowSelectedDate: Dispatch<SetStateAction<boolean>>
1616
selectedMonth: number
1717
selectedYear: number
18-
getFormattedDate: (date: Date | number, formatOptions?: Intl.DateTimeFormatOptions) => string
18+
getFormattedDate: (date: Date | number, formatOptions?: Intl.DateTimeFormatOptions | null | undefined) => string
1919
}
2020

2121
export type Views = "days" | "months" | "years" | "decades"
@@ -63,7 +63,7 @@ const DatePickerProvider = ({ children, options: customOptions, onChange, show,
6363
if (onChange) onChange(date)
6464
}
6565

66-
const getFormattedDate = (date: Date | number, formatOptions?: Intl.DateTimeFormatOptions) => formatDate(options?.language ? options?.language : "en", date, formatOptions)
66+
const getFormattedDate = (date: Date | number, formatOptions?: Intl.DateTimeFormatOptions | undefined | null) => formatDate(options?.language ? options?.language : "en", date, formatOptions)
6767

6868
return (
6969
<DatePickerContext.Provider

src/Utils/date.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export const addYears = (date: Date, amount: number): number => {
3939
return expectedMonth === 1 && newDate.getMonth() === 2 ? newDate.setDate(0) : time
4040
}
4141

42-
export const getFormattedDate = (language: string, date: Date | number, options?: Intl.DateTimeFormatOptions): string => {
42+
export const getFormattedDate = (language: string, date: Date | number, options?: Intl.DateTimeFormatOptions | null | undefined): string => {
4343
let defaultOptions: Intl.DateTimeFormatOptions = {
4444
day: "numeric",
4545
month: "long",

0 commit comments

Comments
 (0)