ra-data-feathers
ra-data-feathers copied to clipboard
iOS/webkit: `Invalid Date`
A KnexJS
/SQLite
date
type field is used as source
for a react-admin
<DateField
.
On PC/Android Chrome/Firefox the field can parse the source
value as date and display it formatted.
On iOS/webkit the <DateField
however render Invalid Date
.
Example date value: 2022-03-15 21:32:21
(year-month-day hour:minute:seconds).
Related, older SO discussion: https://stackoverflow.com/questions/52508501/react-admin-invalid-date-in-safari
Maybe it is related that you are using date input and trying to send a datetime. But It seems not to be a ra-data-feathers bug.
The issue occurs with <DateField />
s. I haven't used date/time inputs, I don't know if the issue also occurs for input components.
Edit: Workaround for making those dates compatible with iOS Safari + proper timezone:
export const iso8601WTz = (dateStr: string): string => {
const date = parseJSON(dateStr);
return date.toISOString();
}
This is currently applied to all date fields responses in a FeathersJS hook.