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

Date in entry slug is not UTC but local #278

Closed
laril opened this issue Dec 20, 2024 · 6 comments
Closed

Date in entry slug is not UTC but local #278

laril opened this issue Dec 20, 2024 · 6 comments
Assignees
Labels
bug Something isn't working

Comments

@laril
Copy link

laril commented Dec 20, 2024

In my setup the posts ase saved using this slug:
slug: "{{year}}-{{month}}-{{day}}-{{hour}}-{{minute}}-{{second}}"

In Decap cms I get files which are using UTC timezone, but it seems that Sveltia is now using local timezone. This now causes for me other issues as the website code expects the times in urls to be specified in UTC.

I don't think I previously had the some problem even with Sveltia, so has something related to this changed in Sveltia?

@kyoshino
Copy link
Member

Will check.

@kyoshino kyoshino self-assigned this Dec 20, 2024
@kyoshino kyoshino added the bug Something isn't working label Dec 20, 2024
@kyoshino kyoshino changed the title Date Date in entry slug is not UTC but local Dec 20, 2024
@kyoshino
Copy link
Member

kyoshino commented Dec 20, 2024

I don’t think I have made a change to Sveltia CMS recently but can confirm the bug. The fix is coming right away.

@kyoshino
Copy link
Member

Fixed in v0.49.5 🙇🏼

kyoshino added a commit that referenced this issue Dec 21, 2024
@jloh
Copy link

jloh commented Dec 30, 2024

Hey @kyoshino I just tried this in v0.51.1 and the slug was still created in local TZ, not UTC. date for my notes is configured like this:

- {
    label: "Publish Date",
    name: "date",
    widget: "datetime",
    default: "{{now}}",
    format: "YYYY-MM-DDTHH:mm:ssZ",
    picker_utc: false,
}

And slug is like this:

path: "{{year}}/{{slug}}"
slug: "{{date | date('YYYY-MM-DD_HHmm')}}"

Does date need to be set to UTC for this to work?

Can open a new issue if thats easier, apologies for posting on an old one.

@kyoshino
Copy link
Member

Will check!

@kyoshino
Copy link
Member

kyoshino commented Dec 30, 2024

In v0.52.0 I’ve added a new option for converting the local date to UTC, so the change won’t break backward compatibility 😉 Pass 'utc' as the second argument for the date transformer:

-slug: "{{date | date('YYYY-MM-DD_HHmm')}}"
+slug: "{{date | date('YYYY-MM-DD_HHmm', 'utc')}}"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy