-
-
Notifications
You must be signed in to change notification settings - Fork 117
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: String to object conversion in Date Pickers
- Loading branch information
1 parent
4eda2c0
commit 90d0c60
Showing
5 changed files
with
26 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,21 @@ | ||
import {useLocalizationContext} from '@mui/x-date-pickers/internals' | ||
|
||
export function hasOwnProperty<X, Y extends PropertyKey>( | ||
obj: X, | ||
prop: Y | ||
): obj is X & Record<Y, unknown> { | ||
return ( | ||
typeof obj === 'object' && | ||
obj !== null && | ||
Object.hasOwnProperty.call(obj, prop) | ||
Object.prototype.hasOwnProperty.call(obj, prop) | ||
) | ||
} | ||
|
||
export function getTimezone<TDate>( | ||
adapter: ReturnType<typeof useLocalizationContext>, | ||
value: TDate | null | ||
): string | null { | ||
return value == null || !adapter.utils.isValid(value) | ||
? null | ||
: adapter.utils.getTimezone(value) | ||
} |