Closed robinbeatty closed 7 months ago
Hi, thanks for getting in touch!
GraphQL doesn’t return an error when you use an atom date because it understands it correctly. If you were to pass an invalid atom date string, you’d get an error. The problem starts once the date is retrieved again in the Control Panel. IntlDateFormatter
doesn’t do particularly well with numerical timezones (e.g. +00:00
). At the moment, if you were to use something like: 2023-11-03 08:00:00 Europe/Berlin
as your string date format, that would work great.
We’ll discuss this further internally.
Craft 4.5.11 is out now, with improved support for mutating Date fields with “Show Time Zone” enabled. Now you can use either one of these formats:
"2023-11-16 09:02:00 America/Los_Angeles"
)date
, time
, and timezone
keys (e.g. "{\"date\":\"2023-11-16\",\"time\":\"09:02:00\",\"timezone\":\"America/Los_Angeles\"}"
)If either of those are used, the time zone will be remembered in the UI.
What happened?
On a Date field that has date and time enabled, with 'Allow authors to set timezone' selected – if we send an atom date down the pipe via GraphQL to this field it's uncaught during the mutation (no errors returned in the response) but when entry is loaded by the CP it breaks giving the trace below. Expect we should get an error in the response (and ideally a hint!).
Btw what format should the string be that this field should expect?
If I remove the timezone flag from the field with the illegal value (one that didn't define the timezone) in the db, the entry loads. So expect should be something to validate it before it lands in the db?
Craft CMS version
4.5.9
PHP version
8.1
Operating system and version
No response
Database type and version
MariaDB 10.4
Image driver and version
No response
Installed plugins and versions
-