Closed hidegh closed 4 months ago
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 .fromISO()
likes that specific format (which is probably fair since it probably isn't a valid ISO date format):
This seemed to work in RunKit, converting to a temp Date object and then passing d.toISOString()
to Luxon's static DateTime.fromISO()
method:
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 https://github.com/moment/luxon/issues/70 using fromSQL
is what 11ty needs to call.
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