Add a date format for download names
The new setting gives the strftime format of {pubdate}, {timestamp} and {last_modified}.
The default is Calibre's "%b, %Y".
This commit is contained in:
@@ -91,6 +91,16 @@ def test_values_follow_the_rules_of_calibre():
|
||||
"Dec, 1999 Oct, 2026"
|
||||
)
|
||||
assert expand("{pubdate}", pubdate="not a date") == ""
|
||||
|
||||
|
||||
def test_date_format():
|
||||
# Calibre's helper_date reference case.
|
||||
assert ft.expand("{pubdate}", ft.prepare(BOOK, 42, date_format="%b %Y")) == "May 2020"
|
||||
assert ft.expand("{pubdate}", ft.prepare(BOOK, 42, date_format="%d/%m/%Y")) == "06_05_2020"
|
||||
assert ft.expand("x{pubdate}x", ft.prepare(BOOK, 42, date_format="")) == "xx"
|
||||
ft.check_date_format("%Y-%m-%d " * 10)
|
||||
with pytest.raises(ft.TemplateError, match="A date format can have 100 characters at most"):
|
||||
ft.check_date_format("x" * 101)
|
||||
# A series without a number has no series_index, and a book without a series has neither.
|
||||
assert expand("{series}{series_index:| [|]}", series_index=None) == "Saga, The"
|
||||
assert ft.expand("{series_index:03d}|{series}", ft.prepare(NO_SERIES, 42)) == "|"
|
||||
|
||||
Reference in New Issue
Block a user