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

picker_utc of datetime widget is broken in #6980, resulting in a timezone mismatch #7132

Closed
hangvane opened this issue Mar 2, 2024 · 4 comments
Labels
area: extensions/widgets/datetime type: bug code to address defects in shipped code

Comments

@hangvane
Copy link

hangvane commented Mar 2, 2024

Describe the bug

picker_utc is broken in #6980, that takes no effect on the behavior of processing timezone.

22370b1#diff-93df641b502cdffd0d6642a8c06ad7ba617a16ee4907262538db0820a966a886L161

As a result, the time displayed stored are mismatched.

If I pick the current time, I will get a time that is 8 hours early (in the filename slug: {{day}}-{{hour}}), and there's no way to change the behavior.

To Reproduce

  1. Add a datetime widget
collections:
  - name: 'Post' # Used in routes, e.g., /admin/collections/blog
    label: 'post' # Used in the UI
    folder: 'source/_posts' # The path to the folder where the documents are stored
    create: true # Allow users to create new documents in this collection
    slug: '{{year}}{{month}}{{day}}-{{hour}}{{minute}}-{{filename}}' # Filename template, e.g., YYYY-MM-DD-title.md
    preview_path: '{{year}}-{{month}}/{{urlname}}.htm'
    fields: # The fields for each document, usually in front matter
      - {label: 'title', name: 'title', widget: 'string'}
      - {label: 'filename', name: 'filename', widget: 'string'}
      - {label: 'urlname', name: 'urlname', widget: 'string'}
      - {label: 'date', name: 'date', widget: 'datetime', picker_utc: true}
  1. Edit the date in the UI
  2. Check the front-matter and filename of the generated markdown file.

Expected behavior

The stored datetime string should be the same as picked.

Screenshots

Applicable Versions:

  • Decap CMS version: 3.1.1
  • Git provider: GitHub
  • OS: Windows 11
  • Browser version chrome 112

CMS configuration

collections:
  - name: 'Post' # Used in routes, e.g., /admin/collections/blog
    label: 'post' # Used in the UI
    folder: 'source/_posts' # The path to the folder where the documents are stored
    create: true # Allow users to create new documents in this collection
    slug: '{{year}}{{month}}{{day}}-{{hour}}{{minute}}-{{filename}}' # Filename template, e.g., YYYY-MM-DD-title.md
    preview_path: '{{year}}-{{month}}/{{urlname}}.htm'
    fields: # The fields for each document, usually in front matter
      - {label: 'title', name: 'title', widget: 'string'}
      - {label: 'filename', name: 'filename', widget: 'string'}
      - {label: 'urlname', name: 'urlname', widget: 'string'}
      - {label: 'date', name: 'date', widget: 'datetime', picker_utc: true}

Additional context

@martinjagodic
Copy link
Member

A fix is released in v3.1.6 (#7091). @hangvane can you please test if it works now?

@msfjarvis
Copy link

This is still broken for me, when I try to use Decap to update a date I lose the TZ component and the invalid date causes Hugo to start ignoring that post. The change I made to my config.yml file is here, and this is what Decap did when I updated the date on a blog post: msfjarvis/msfjarvis.dev@feb7f75

@demshy
Copy link
Member

demshy commented Apr 3, 2024

@msfjarvis we also stumbled upon this issue on one of our projects, patch released just now in 3.1.8 seems so solve it for us. Do you mind checking it out?

@msfjarvis
Copy link

@msfjarvis we also stumbled upon this issue on one of our projects, patch released just now in 3.1.8 seems so solve it for us. Do you mind checking it out?

v3.1.8 fixed it, thank you!

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

4 participants