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

The date field does not work correctly #7166

Closed
Juniors017 opened this issue Apr 4, 2024 · 10 comments
Closed

The date field does not work correctly #7166

Juniors017 opened this issue Apr 4, 2024 · 10 comments
Labels
area: extensions/widgets/datetime type: bug code to address defects in shipped code

Comments

@Juniors017
Copy link

Juniors017 commented Apr 4, 2024

I qualify the date field with :

- label: "Date" name: "Date" widget: datetime date_format: "DD.MM.YYYY" # e.g. 24.12.2021 hint: 'Date de publication'
If today date is 03/04/2024 (DD/MM/YYYY)
I select date "now" but decapCMS add 04/03/2024 Day and Month are reverse
image
But in preview is OK
image
in frontmatter is KO

i use this script for use decap : <script src="https://unpkg.com/decap-cms@^3.0.0/dist/decap-cms.js"></script>

@Juniors017 Juniors017 added the type: bug code to address defects in shipped code label Apr 4, 2024
@demshy
Copy link
Member

demshy commented Apr 11, 2024

should be fixed with 3.1.9 version, could you please try again and confirm?

@Juniors017
Copy link
Author

should be fixed with 3.1.9 version, could you please try again and confirm?

if you use this it's OK

- label: "Date de création"
      name: "date"
      widget: datetime
      default: ""
      hint: 'Date de création'  
      format: 'L'

if you use this it's OK

- label: "Date de création"
      name: "date"
      widget: datetime
      default: ""
      hint: 'Date de création'  
      format: 'LLL'

and if you use this it's OK

- label: "Date"
      name: "Date"
      widget: datetime
      date_format: "DD.MM.YYYY" # e.g. 24.12.2021
      hint: 'Date de publication'

thanks

@adrian5
Copy link
Contributor

adrian5 commented Jul 19, 2024

Is this really fixed? It doesn't work for me on DecapCMS 3.1.11, I still get the U.S. date format:

datetime

fields:
  - { label: "Title", name: "title", widget: "string"}
  - {
      label: "Begins",
      name: "begins",
      widget: "datetime",
      format: "YYYY-MM-DDTHH:mm:ss",
      date_format: "DD.MM.YYYY", # ignored?
      time_format: "HH:mm" # ignored?
    }

@martinjagodic
Copy link
Member

@adrian5 see #7250, there is a mismatch between the docs and implementation. I am closing this issue in favor of that one.

@adrian5
Copy link
Contributor

adrian5 commented Aug 8, 2024

@martinjagodic Issue #7250 seems to focus on the storage format (backend) though. I'm unable to configure the UI (frontend) in the way the documentation claims, and NetlifyCMS was able to.

@martinjagodic
Copy link
Member

@adrian5 you cannot alter the display format with CMS config. It's the HTML datetime-local input, so the display format is based on the user's browser locale.

@adrian5
Copy link
Contributor

adrian5 commented Aug 19, 2024

@martinjagodic Hmm, I see. I could swear this used to work just fine in NetlifyCMS.

What is the meaning of the documentation?

date_format: sets date display format in UI; boolean or Day.js formats. If used without time_format, only the date picker is displayed.

@martinjagodic
Copy link
Member

You have a point here, thanks for raising it. I will change the docs to clarify that it's the frontmatter format and that the display format is based on the browser locale.

I could swear this used to work just fine in NetlifyCMS.

I believe you. We had to update it because it used some unmaintained dependencies and affected other areas of the CMS. I opted for native HTML inputs to avoid such problems in the future.

@adrian5
Copy link
Contributor

adrian5 commented Aug 20, 2024

Understood. Thanks for clarifying!

@weeix
Copy link
Contributor

weeix commented Aug 24, 2024

I attempted to change the picker's format to 24-hour but also found the documentation confusing. It turns out the picker's format is entirely dependent on the web browser's UI language (not the 1st language).

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

No branches or pull requests

5 participants