Closed nikhiljha closed 4 years ago
Hm the panic definitely needs to be fixed. As for the format, see the TOML spec: https://github.com/toml-lang/toml#user-content-offset-date-time but your example should work according to https://github.com/toml-lang/toml#local-date-time
The documentation does specify the accepted date formats, which are unfortunately much stricter than TOML.
# The date of the post.
# Two formats are allowed: YYYY-MM-DD (2012-10-02) and RFC3339 (2002-10-02T15:00:00Z).
As for Python, you need to specify a tzinfo to get timestamps with a timezone. E.g.
>>> from datetime import *
>>> datetime.now(timezone(timedelta(hours=-7))).replace(microsecond=0).isoformat()
'2020-06-05T15:12:15-07:00'
And for BSD date, use date +%Y-%m-%dT%H:%M:%S%z
.
Ideally the front-matter should support any date allowed by the TOML spec. The only restriction being when putting the date in the filename for Windows reasons.
I agree that would be nice. I don't know how to use the toml parser to do that, though. And chrono doesn't support parsing dates without a format. Maybe we should have a bunch of allowed strftime formats that are tried one by one?
Disregard my last comment. All that was really missing was RFC3339 with the timezone removed. The PR now addresses that.
Environment
Zola version: 0.10.1
Expected Behavior
There should be an error message that the date string is badly formatted, instead of a cryptic error message.
Current Behavior
Step to reproduce
Make a page with a badly formatted date, like so (it should have a
+00:00
at the end).Side note
How are you supposed to generate the type of date string that zola wants? On MacOS, the
date
command doesn't have an ISO8601 mode, and Pythondatetime.now().isoformat()
outputs something that Zola doesn't understand (and makes it panic).