add iso formatted week tokens

This commit is contained in:
Liquidmantis
2021-12-11 09:33:21 -07:00
parent f06142d50f
commit 626b800676
2 changed files with 7 additions and 0 deletions

View File

@@ -633,6 +633,9 @@ Currently, the following substitutions will be made during new note creation:
| `{{week}}` | week of the year | 46 | | `{{week}}` | week of the year | 46 |
| `{{lastweek}}` | prior week of the year | 45 | | `{{lastweek}}` | prior week of the year | 45 |
| `{{nextweek}}` | next week of the year | 47 | | `{{nextweek}}` | next week of the year | 47 |
| `{{isoweek}}` | week of the year in iso format | 2021-W46 |
| `{{lastisoweek}}` | prior week of the year in iso format | 2021-W45 |
| `{{nextisoweek}}` | next week of the year in iso format| 2021-W47 |
| `{{year}}` | year | 2021 | | `{{year}}` | year | 2021 |
As an example, this is my template for new notes: As an example, this is my template for new notes:

View File

@@ -203,6 +203,7 @@ local function calenderinfo_today()
local oneweek = 7 * oneday local oneweek = 7 * oneday
local date_format = "%Y-%m-%d" local date_format = "%Y-%m-%d"
local week_format = "%V" local week_format = "%V"
local isoweek_format = "%Y-W%V"
local opts = {} local opts = {}
opts.date = os.date(date_format) opts.date = os.date(date_format)
opts.yesterday = os.date(date_format, os.time() - oneday) opts.yesterday = os.date(date_format, os.time() - oneday)
@@ -225,6 +226,9 @@ local function calenderinfo_today()
opts.week = os.date(week_format) opts.week = os.date(week_format)
opts.lastweek = os.date(week_format, os.time() - oneweek) opts.lastweek = os.date(week_format, os.time() - oneweek)
opts.nextweek = os.date(week_format, os.time() + oneweek) opts.nextweek = os.date(week_format, os.time() + oneweek)
opts.week = os.date(isoweek_format)
opts.lastisoweek = os.date(isoweek_format, os.time() - oneweek)
opts.nextisoweek = os.date(isoweek_format, os.time() + oneweek)
opts.month = dinfo.month opts.month = dinfo.month
opts.year = dinfo.year opts.year = dinfo.year
opts.day = dinfo.day opts.day = dinfo.day