decaporg / decap-cms

A Git-based CMS for Static Site Generators
https://decapcms.org
MIT License
17.67k stars 3.03k forks source link

Error editing with datetime widget - wrongly converts PM values to AM equivalent time #7066

Closed finalarena closed 5 months ago

finalarena commented 5 months ago

Describe the bug When using the date time picker in the datetime widget, upon selecting a PM time (e.g. 17:30), the preview incorrectly displays a 12-hour AM equivalent (e.g. 05:30).

Upon saving the CMS collection item, the correct value is saved to the .md file.

However, upon opening the file again in the editor, the date time picker is incorrectly populated with the 12-hour equivalent time again, and re-saving the entry therefore saves the incorrect time.

To Reproduce

  1. Edit item with a field with widget 'datetime'

  2. click to init the date time picker

  3. select a PM tie e.g. 17:30

  4. Observe that the preview incorrectly says 05:30 image

  5. Save the item

  6. Observe the saves value is correctly 17:30

  7. click to launch the datetpicker again

  8. observe that the init value in the picker is incorrectly 05:30 image

Expected behaviour The preview for the time should match the AM/PM/24hour clock version of the selected time. The init value in the date picker should not format the time to a 12-hour clock value.

value={dayjs(value).format('YYYY-MM-DDThh:mm')} in the Control seems to cause a conversion to the 12-hour equivalent time.

Applicable Versions:

CMS configuration

Additional context I believe the docs still refer to momentjs config vs. dayjs.