Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
finalarena opened this issue Jan 27, 2024 · 0 comments · Fixed by #7072
Closed
Assignees
Labels
area: extensions/widgets/datetime type: bug code to address defects in shipped code

Comments

@finalarena
Copy link

finalarena commented Jan 27, 2024

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:

  • Decap CMS version: decap-cms-app 3.1.0-beta.4
  • Git provider: GitHub
  • OS: Windows 11, OSX
  • Browser version: safari 17.2.1, Chrome 120
  • Node.JS version: v18.17.1

CMS configuration
- { label: "End Date", name: "dateend", widget: "datetime" }

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

@finalarena finalarena added the type: bug code to address defects in shipped code label Jan 27, 2024
@martinjagodic martinjagodic self-assigned this Jan 30, 2024
martinjagodic added a commit that referenced this issue Jan 30, 2024
- from 12-hour to 24-hour format
- replace moment references in the docs

#7066
martinjagodic added a commit that referenced this issue Jan 30, 2024
- from 12-hour to 24-hour format
- replace moment references in the docs

#7066

Co-authored-by: Anze Demsar <anze.demsar@p-m.si>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: extensions/widgets/datetime type: bug code to address defects in shipped code
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants