-
-
Notifications
You must be signed in to change notification settings - Fork 494
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
FR: better date parsing in front matter #1669
Comments
Under the hood, Eleventy is using Luxon so it might be worth filling an issue with them, too. |
Interesting. This seems to be parseable in JavaScript w/ ye olde Date constructor: const d = new Date("2019-08-08 14:10:00 +0800");
console.log(d); // Wed Aug 07 2019 23:10:00 GMT-0700 (Pacific Daylight Time) But it doesn't look like Luxon's Lines 744 to 756 in 65d8d6d
This seemed to work in RunKit, converting to a temp Date object and then passing const {DateTime} = require("luxon");
const d = new Date("2019-08-08 14:10:00 +0800");
let date = DateTime.fromISO(d.toISOString(), { zone: "utc" });
if (!date.isValid) {
throw new Error(
`date front matter value (x) is invalid for y`
);
}
console.log(date); So I'm guessing it isn't really a bug in Luxon and 11ty needs to try parsing the date before passing it off to Luxon, or, just don't put spaces in your date formats. |
Thanx guys, based on luxon's docs moment/luxon#70 using |
#867 fixes this. |
Describe the bug
Time zone information in the front matter inside a date results in an error, if it's entered as below. Other frameworks (HUGO, HEXO, JEKYLL) were more flexible.
I do understand that the format
2019-08-08 14:10:00 +0800
is not a standard, but it's very readable (human like). So it should be accepted/preferred over the2019-08-08T14:10:00+0800
.Below is the front matter and error it produces, for the non-standardly formatted date.
The error is:
To Reproduce
Use date in the format provided in this sample above.
Expected behavior
Flexible date parsing.
Screenshots
If applicable, add screenshots to help explain your problem.
N/A
Environment:
Additional context
N/A
The text was updated successfully, but these errors were encountered: