1
0
mirror of https://github.com/squidfunk/mkdocs-material.git synced 2024-11-14 19:07:41 +01:00
mkdocs-material/material/plugins
Alexander Payne abfac1a93e
Switched to Babel's format_datetime to allow for time in formatted dates (#6981)
* Use Babel's `format_datetime`, not `format_date`

I am using MkDocs-Material 9.5.15 and Babel 2.14.0. When setting the config value `blog.post_date_format: "yyyy-MM-dd hh:mm:ss"`, the blog plugin crashes during compilation with the error "date objects have no hour field".

I believe this is occurring because the plugin provides a `datetime` to `babel.dates.format_date`, which upcasts it to a plain, timeless, `date`. Making this change to use `babel.dates.format_datetime` instead resolved the error and demonstrated expected behavior.

While I recognize that it is likely uncommon for a blog to want to include sub-date timestamps in any of these fields, I believe that the current documentation,

> The format string must adhere to babel's pattern syntax and should not contain whitespace

implies that _any_ of Babel's pattern markers are acceptable here. I would consider 

> The format string must adhere to Babel's pattern syntax for calendar dates and should not contain whitespace

to also be a sufficient fix for this case.

----

Thank you for your effort in creating this project; it has been a wonderful benefit to my team, and this is the first minor problem we've had in months of using it.

* Make the change in src/, not material/
2024-03-31 15:45:47 +08:00
..
blog Switched to Babel's format_datetime to allow for time in formatted dates (#6981) 2024-03-31 15:45:47 +08:00
group Updated copyright year 2024-01-06 09:27:06 +07:00
info Fixed UTF-8 with BOM encoding support 2024-03-17 12:04:45 +07:00
offline Updated copyright year 2024-01-06 09:27:06 +07:00
privacy Fixed UTF-8 with BOM encoding support 2024-03-17 12:04:45 +07:00
search Fixed inability to reset search pipeline 2024-03-12 09:07:29 +07:00
social Fixed social plugin Google Fonts integration 2024-03-31 15:23:22 +08:00
tags Updated copyright year 2024-01-06 09:27:06 +07:00
__init__.py Updated copyright year 2024-01-06 09:27:06 +07:00