-
Notifications
You must be signed in to change notification settings - Fork 17
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
[BUG] TypeError: strptime() argument 1 must be str, not datetime.date #48
Labels
Comments
Thank you for reporting this! Actually, I didn't know the parser will parse things into If you want a temporary fix, wrap the date with quotes to make it recognized as a string. I will try to implement the feature you requested as well. |
Will it be ok to send a PR? |
Sure! |
jgraichen
added a commit
to jgraichen/mkdocs-blogging-plugin
that referenced
this issue
Apr 12, 2023
When valid YAML dates or times are added to the page frontmatter, the YAML parser will already convert them to datetime.date or datetime.datetime objects. Example: --- date: 2023-04-12 --- This resulted in #strptime raising a TypeError because datetime.date isn't a string. This commit changes the plugin code to always accept a native datetime.date or datetime.datetime, even if meta_time_format is not set, and handle them without string parsing. Close liang2kl#48
jgraichen
added a commit
to jgraichen/mkdocs-blogging-plugin
that referenced
this issue
Apr 12, 2023
When valid YAML dates or times are added to the page frontmatter, the YAML parser will already convert them to datetime.date or datetime.datetime objects. Example: --- date: 2023-04-12 --- This resulted in #strptime raising a TypeError because datetime.date isn't a string. This commit changes the plugin code to always accept a native datetime.date or datetime.datetime, even if meta_time_format is not set, and handle them without string parsing. Close liang2kl#48
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Describe the bug
The YAML parser already converts time formats in the frontmatter into datetime objects. If reading from frontmatter is enabled, building the page fails with:
To Reproduce
Steps to reproduce the behavior:
Configure
mkdocs.yml
:Create an article with one of the following metadata values:
Expected behavior
Building the page should not fail.
Otherwise, it would be nice if an available
date
anddatetime
would be taken without configuringmeta_time_format
, if it already is a valid date by YAML. This would make the blogging plugin compatible with mkdocs-rss-plugin.Maybe something like this:
Environment (please complete the following information):
Additional context
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered: