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

Invalid Date format #413

Closed
DirtyF opened this issue Feb 14, 2019 · 10 comments
Closed

Invalid Date format #413

DirtyF opened this issue Feb 14, 2019 · 10 comments
Labels
bug: dependency A problem in one of Eleventy’s dependencies education waiting-to-close Issue that is probably resolved, waiting on OP confirmation.

Comments

@DirtyF
Copy link
Contributor

DirtyF commented Feb 14, 2019

Given I import a blog post from Jekyll
When I run eleventy
Then  an error is raised: `Error: date front matter value (2018-11-20 16:33 +0100) is invalid`

According to https://www.11ty.io/docs/dates/, it's not valid. 😞

That means I have to change the date of all my existing posts?

@DirtyF DirtyF changed the title Date format in front matter? Invalid Date format Feb 14, 2019
@zachleat
Copy link
Member

zachleat commented Mar 8, 2019

Where did this date format come from? It’s not a valid YAML or UTC String?

@zachleat zachleat added the open-question Requires additional information before we can proceed. label Mar 8, 2019
@DirtyF
Copy link
Contributor Author

DirtyF commented Mar 9, 2019

According to https://yaml.org/type/timestamp.html:

a more relaxed format is also supported for enhanced readability, using white space separation.

@zachleat
Copy link
Member

Oh interesting. Are you sure those aren’t accidentally strings? Doesn’t look like YAML tries to parse them at all, as that error comes from a fallback condition where Luxon tries to parse the date string: https://github.com/11ty/eleventy/blob/master/src/Template.js#L613

@zachleat
Copy link
Member

Can you attach an example of the front matter that’s failing?

@DirtyF
Copy link
Contributor Author

DirtyF commented Mar 13, 2019

Here is an example of a Forestry output, leading to the same error:

---
subtitle: New doc page
date: 2019-03-13 20:18:42 +0000
tags:
- docs
---

@zachleat
Copy link
Member

Alright I dove in a bit deeper on this and I think it’s a js-yaml bug. We use gray-matter which uses js-yaml.

They have a live demo here: https://nodeca.github.io/js-yaml/

image

Your example returns a string. The following formats do work:

image

image

For comparison YAMLlint thinks your date format is valid, albeit it corrects the formatting by adding a colon to 00:00:

image

image

Can you file this upstream and provide a link back? https://github.com/nodeca/js-yaml
http://www.yamllint.com/

@zachleat zachleat added bug: dependency A problem in one of Eleventy’s dependencies on-hold and removed open-question Requires additional information before we can proceed. labels Mar 23, 2019
zachleat added a commit that referenced this issue Mar 23, 2019
@zachleat
Copy link
Member

Hmm, sorry that was closed—but he may be right.

Note that the string result does match the pyyaml implementation:
image

Here’s the relevant time zone bit from the YAML 1.1 spec (I wasn’t able to actually find this in the YAML 1.2 spec? That might be worth digging deeper into)

(([ \t]*)Z|[-+][0-9][0-9]?(:[0-9][0-9])?)? # (time zone)

Note that if the four digit format is used, it requires the :.

@zachleat
Copy link
Member

Also note that in the discussion above “a more relaxed format is also supported for enhanced readability, using white space separation” refers to the whitespace between the time and the time zone, not whitespace between the timezone hours and timezone minutes.

space separated: 2001-12-14 21:59:43.10 -5

Sorry 😲

@zachleat
Copy link
Member

Worth noting that feature request #335 may give you an easier out here? Not sure. Might let you avoid having to update all of your data.

@wangzhankun
Copy link

Hello, I run into the same trouble,

---
date: 2023-12-08 17:02:02
tags:
  - 用户态驱动
  - OS/Linux
dg-publish: "true"
---

What is wrong with the formatter?
The issue I posted is at oleeskild/digitalgarden/issues/236

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug: dependency A problem in one of Eleventy’s dependencies education waiting-to-close Issue that is probably resolved, waiting on OP confirmation.
Projects
None yet
Development

No branches or pull requests

3 participants