Support different date formats in templates#197
Conversation
|
Hi, I was looking for the date problem in the headers and I found this. Thanks. |
|
A workaround is to install vscode "English (United Kingdom)" language pack. |
Can you make example how to use the placeholder. I did set the headerTemplate in the settings as given but it rendert no date |
|
Hi, |
|
Hi @yzane, |
|
Also waiting for this - but the author seems to have gone missing from March 2020. |
|
I did the same as @giminni and it worked like a charm. |
|
Thanks for your PR! |
This already came up before in #74 and #95 but I am not happy with leaving this to the locale default format. My VS Code is also in a different locale (English) than the format I would have wanted to use (German).
So I came up with a different way that allows transformations to be applied on the header and footer templates before they are passed to puppeteer. That way, one can skip the
<span class="date"></span>part and just use placeholders that are replaced directly.The supported placeholders for now are:
%%ISO-DATETIME%%– For an ISO-based date and time format:YYYY-MM-DD hh:mm:ss%%ISO-DATE%%– For an ISO-based date format:YYYY-MM-DD%%ISO-TIME%%– For an ISO-based time format:hh:mm:ssI originally wanted to allow for completely custom formats but that would require some additional dependencies to format dates properly as one shouldn’t reinvent that.
With these placeholder, I can now simply configure my header template like this: