- Notifications
You must be signed in to change notification settings - Fork244
Do you want to add more template.substitution like {{yesterday}} ?#475
fcarvalhopacheco started this conversation inCookbook
-
On your obsidian.lua configuration: -- Optional, for templates (see below).templates= {subdir='Templates',date_format='%Y-%m-%d',time_format='%H:%M',-- A map for custom variables, the key should be the variable and the value a functionsubstitutions= {time24=function()returnos.date'%H:%M:%S'end,time12=function()-- Conversion to 12-hour format with AM/PMlocalhour=tonumber(os.date'%H')localampm=hour>=12and'PM'or'AM'hour=hour%12hour=hour==0and12orhourreturnstring.format('%02d:%s %s',hour,os.date'%M:%S',ampm)end,year=function()returnos.date('%Y',os.time())end,month=function()returnos.date('%B',os.time())end,yesterday=function()returnos.date('%Y-%m-%d',os.time()-86400)end,nextday=function()returnos.date('%Y-%m-%d',os.time()+86400)end,hdate=function()returnos.date'%A, %B %d, %Y'end,rfc3339=function()returnos.date'!%Y-%m-%dT%H:%M:%SZ'end,week=function()returnos.date('%V',os.time())end,isoweek=function()returnos.date('%G-W%V',os.time())end,isoprevweek=function()localadjustment=-7*24*60*60-- One week in secondsreturnos.date('%G-W%V',os.time()+adjustment)end,isonextweek=function()localadjustment=7*24*60*60-- One week in secondsreturnos.date('%G-W%V',os.time()+adjustment)end,day_of_month=function()returnos.date('%d',os.time())end,month_numeric=function()returnos.date('%m',os.time())end,weekday=function()returnos.date('%A',os.time())end, }, }, Below is a detailed table of custom variables available for template substitutions.
Reference:#473 |
BetaWas this translation helpful?Give feedback.
All reactions
🎉 2
Replies: 0 comments
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment