adminjs icon indicating copy to clipboard operation
adminjs copied to clipboard

fix: fix property type 'date' when backend returns an iso string

Open dziraf opened this issue 1 year ago • 3 comments

Fixes issue related to https://github.com/SoftwareBrothers/adminjs/issues/1691

@AshotN this fixes a bug where date values were rendered as NaN-NaN-NaN if backend returned an ISO string instead of a simple date string while having the property's type set to date instead of datetime.

dziraf avatar Aug 13 '24 13:08 dziraf

Makes sense, I haven't been able to test on my actual project yet. But looking at the changes it looks good to me. Sorry for introducing that issue

AshotN avatar Aug 13 '24 18:08 AshotN

I'll have to give this more thought. If the database/backend stores datetimes using UTC timezone and the user's timezone is i.e. GMT+4, this will convert backend's 2024/08/13 11:00PM to 2024-08-13, while that should be 2024-08-14 in the user's timezone.

dziraf avatar Aug 14 '24 12:08 dziraf

My thought process was for date's with no time. We should display exactly what the DB is storing, so 2024-01-01 no matter where you are should display 2024-01-01. For editing I can see it either way, if your local timezone should be converted to UTC, or just write it as you input it. The latter is more intuitive at face value. But I'm not sure what people would expect more

AshotN avatar Aug 14 '24 22:08 AshotN

Hi there, Upgrading from 7.8.1 to 7.8.12 gave me the NaN-NaN-NaN issue. Waiting for this fix to be deployed. Thanks

phprelated avatar Sep 06 '24 10:09 phprelated

I'll merge this for now. We should consider using https://www.npmjs.com/package/@formkit/tempo for dates in the meantime

dziraf avatar Sep 18 '24 08:09 dziraf

:tada: This PR is included in version 7.8.13 :tada:

The release is available on:

Your semantic-release bot :package::rocket:

github-actions[bot] avatar Sep 18 '24 08:09 github-actions[bot]