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

Fix use local timezone unintentionally when parse date from filename #1752

Merged

Conversation

knokmki612
Copy link
Contributor

@knokmki612 knokmki612 commented Apr 30, 2021

Step to reproduce (What is the problem)

Demo: https://knokmki612.github.io/sandbox-11ty/

$ git clone https://github.com/knokmki612/sandbox-11ty.git
$ cd sandbox-11ty
$ yarn install
$ yarn eleventy
$ cat _site/parse-date-from-front-matter/index.html

<h1>Parse date from front matter</h1>

<p>date: Fri, 30 Apr 2021 00:00:00 GMT</p>
$ cat _site/2021-04-30/index.html

<h1>Parse date from filename</h1>

<p>date: Thu, 29 Apr 2021 15:00:00 GMT</p>

Doesn't match the results of date parsing between front-matter and filename.

This caused by unspecified the UTC timezone when parse date from filename.

According to official document, page.date must be the midnight of UTC
(in case of above example: Fri, 30 Apr 2021 00:00:00 GMT)

Environment

  • My timezone: Asia/Tokyo (GMT +09:00)

@knokmki612 knokmki612 changed the title Fix no use local timezone when parse date from filename Fix use local timezone when parse date from filename May 5, 2021
@knokmki612 knokmki612 changed the title Fix use local timezone when parse date from filename Fix use local timezone unintentionally when parse date from filename May 5, 2021
@zachleat zachleat merged commit f1b85b3 into 11ty:master Jul 27, 2021
@zachleat
Copy link
Member

Good catch, thank you!

@zachleat zachleat added this to the Eleventy 1.0.0 milestone Jul 27, 2021
@knokmki612 knokmki612 deleted the fix-timezone-when-parse-date-from-filename branch July 27, 2021 12:29
@zachleat
Copy link
Member

Looks like this broke a test locally but not on GitHub actions 😱

I filed a bug with the liquidjs library, I guess we were relying on this local timezone to pass into the liquid date filter: harttle/liquidjs#375

@zachleat
Copy link
Member

For future me, here’s the test that broke:

2016-02-01-permalinkdate.liquid:

---
title: Date Permalink
permalink: "/{{ page.date | date: '%Y/%m/%d' }}/index.html"
---
Date Permalinks

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants