foam icon indicating copy to clipboard operation
foam copied to clipboard

Add a date variable for templates in ISO 8601 format

Open dstengle opened this issue 7 months ago • 2 comments

Is your feature request related to a problem? Please describe.

I made my own "created" forematter item in my templates and just discovered it is wrong and now I have hundreds of files with incorrectly formatted datetime entries.

Describe the solution you'd like

As a user that is creating a template, I would like to have a variable available with the ISO8601 datetime as described here https://en.wikipedia.org/wiki/ISO_8601#Combined_date_and_time_representations so that I do not have to figure out the correct format myself.

Describe alternatives you've considered

I made the format manually in my templates and have a misplaced ":" that breaks correct parsing in other software.

Screenshots or Videos

No response

dstengle avatar Dec 28 '23 18:12 dstengle

Just found out it was even more screwed up because my templates had a unicode HYPHEN (\u2010) instead of HYPHEN-MINUS (\u002d) which I must of copy-pasted from somewhere.

dstengle avatar Dec 28 '23 19:12 dstengle

Good point, the easy solution here is to just add a FOAM_DATE_ISO variable which returns the Foam date in ISO format (see variable-resolver.ts).

At some point I have been thinking of adding a more powerful templating engine, basically something that can run JS so that there is more flexibility around templates, but I haven't thought through it yet.

riccardoferretti avatar Dec 28 '23 22:12 riccardoferretti