sveltia / sveltia-cms

Alternative to Netlify/Decap CMS. Fast, lightweight, Git-based headless CMS. Modern UX, first-class i18n support, open source & free. Made with Svelte.
MIT License
750 stars 34 forks source link

Incorrect datetime format in markdown frontmatter #99

Closed FinallyCanuck closed 5 months ago

FinallyCanuck commented 5 months ago

In posts using Decap, datetiime was returned as, for example: date: 2023-04-09T22:38:00.000Z

In a new post I've made using Sveltia, it produces:

date: 2024-01-29T23:10

This creates an Invalid DateTime display in on my rendered page.

For reference, here is a snippet of my config (that hasn't been changed since move to Sveltia.

fields:
  - { label: "Title", name: "title", widget: "string" }
  - { label: "Description", name: "description", widget: "string" }
  - { label: "Author", name: "author", required: false, widget: "string" }
  - { label: "Publish Date", name: "date", widget: "datetime" }

When I refer to the Decap docs, the datetime formatting appears to reflect how it should appear in the CMS UI, not the output.

Any thoughts on how to return to the previous format?

kyoshino commented 5 months ago

Hey @FinallyCanuck, thanks for reporting the issue. I’ll figure out what’s happening here.

kyoshino commented 5 months ago

I was sort of confused with the storage format (format) and display format (date_format and time_format) options. But I thought the latter options would affect the storage format as well, because if date_format or time_format is false, saving the date in the complete ISO 8601 format is impossible. I’ll double-check the behaviour of Netlify/Decap CMS later. Handling date/time is so hard 🫠

kyoshino commented 5 months ago

Sorry for the delay. Just shipped v0.9.9 to fix this particular issue.

I’ll revisit other date/time issues later this week or next week and write automated tests. It’s a good time to do so as Decap CMS 3.1 was out to replace moment.js with day.js as the datetime widget’s formatting library. Sveltia CMS follows the change.

FinallyCanuck commented 5 months ago

No apologies required. Thank you for looking into this so quickly.