View Single Post
Old 10-11-2023, 05:17 PM   #655
chaley
Grand Sorcerer
chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.
 
Posts: 12,529
Karma: 8075744
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by ownedbycats View Post
Just out of curiosity, I put this in the template tester:



I always end up with [year]-10-15. Where does the October 15th date come from? I thought it'd be the current date, but it's only the 11th where I live.
The template processor uses calibre's date parser, which is dateutil. When it parses a date, missing fields come from "default". In calibre, default is specified as
Code:
func = datetime.utcnow if assume_utc else datetime.now
default = func().replace(day=15, hour=0, minute=0, second=0, microsecond=0,
                tzinfo=_utc_tz if assume_utc else _local_tz)
The variable assume_utc is False.

As such, a missing month is the current local month and a missing day is the 15th. A missing time becomes midnight. I don't know if one can have a missing year, but if so then it would be the current year.
chaley is offline   Reply With Quote