Open
Description
The datetime
field currently captures dates in local time, using an <input>
of type datetime-local
. However, these values are serialized to content files as UTC by appending a "Z", without correctly adjusting the local time to UTC:
serialize(value) {
if (value === null) return { value: undefined };
const date = new Date(value + 'Z');
date.toJSON = () => date.toISOString().slice(0, -8);
date.toString = () => date.toISOString().slice(0, -8);
return { value: date };
},
This implementation requires content users to manually adjust deserialized Date
objects to the time zone of the content editor, which may not always be known.
Instead, the datetime
fields should convert its data from local time to UTC before serialization. This would ensure predictable alignment between content editors and content users.
Overview:
- The datetime-local input type captures dates in local time.
- The current implementation appends a "Z" to the local time, indicating UTC, without converting the local time to UTC.
- This can lead to inconsistencies and unexpected behavior when the serialized date is interpreted as UTC.
- The datetime component should convert the local time to UTC before serializing.
- This change will ensure that the serialized date is consistently interpreted as UTC, leading to more predictable behavior.
Metadata
Metadata
Assignees
Labels
No labels