Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Do you want to add more template.substitution like {{yesterday}} ?#475

fcarvalhopacheco started this conversation inCookbook
Discussion options

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.

SpecifierExpands toExample
{{time24}}Current time in 24-hour format"14:45:00"
{{time12}}Current time in 12-hour format with AM/PM"2:45:00 PM"
{{year}}Current year"2024"
{{month}}Month name"March"
{{yesterday}}Yesterday’s date in ISO format"2024-03-05"
{{nextday}}Tomorrow’s date in ISO format"2024-03-07"
{{hdate}}Current date in a human-readable format"Wednesday, March 6, 2024"
{{rfc3339}}Current date and time in RFC3339 format"2024-03-06T14:45:00+00:00"
{{week}}Week number of the year"10"
{{isoweek}}ISO week number of the current week"2024-W10"
{{isoprevweek}}ISO week number of the previous week"2024-W09"
{{isonextweek}}ISO week number of the next week"2024-W11"
{{day_of_month}}Day of the month"06"
{{month_numeric}}Month as a numeric value"03"
{{weekday}}Name of the weekday"Wednesday"

Reference:#473

You must be logged in to vote

Replies: 0 comments

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Labels
None yet
1 participant
@fcarvalhopacheco

[8]ページ先頭

©2009-2025 Movatter.jp