ra-data-feathers icon indicating copy to clipboard operation
ra-data-feathers copied to clipboard

iOS/webkit: `Invalid Date`

Open strarsis opened this issue 2 years ago • 2 comments

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

strarsis avatar Mar 16 '22 15:03 strarsis

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.

josx avatar Mar 17 '22 20:03 josx

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.

strarsis avatar Mar 17 '22 21:03 strarsis