joplin / joplin/plugin-templates
Be able to specify exact dates as well as relative dates
- Dominant language
- TypeScript
- Stars
- 207
- Forks
- 40
- Avg merge
- 7d 16h
- Merged PRs (30d)
- 2
Description
Currently, the code in src/helpers/datetime.ts allows for setting deltas relative to some date, but that date can only be today's date (`{{date}}`) or two beginning of the week options(`{{bowm}}`/`{{bows}}`).
It would be nice to be able to specifically set some values in the datetime, rather than have to rely on relative changes, eg if I'm making a diary for the month, with daily headers, and want to find the first day of the month, I need to use something like this:
```
{{datetime set_date_=date delta_days=(math (math (datetime set_date=date format="DD") "*" -1) "+" 1)}}
```
(Which works by extracting the day of the month, subtracting it and adding 1)
Whereas it would be nice to shortcut that with:
```
{{datetime set_date=date set_day=1}}
```
(Essentially, this is just asking for the functionality of `set_date` and `set_time` to be exposed to the user more granularly)
I think the specific order these are applied in should be:
- Set date and time
- Set components of date and time (day/month/hours/minutes/seconds)
- Adjust using deltas
This would also allow for cool stuff like:
```
{{#repeat (datetime set_date=date set_day=1 delta_month=1 delta_day=-1 format="DD")}}
# Day {{math repeat_index "+" 1}}
Today's date: {{datetime set_date=date set_day=(math repeat_index "+" 1)}}
{{/repeat}}
```
To create a whole month of diary entries automatically (it finds the number of days by setting today's date, setting it to the first of the month, adding a month to get to next month, and then rolling back a day to find the last day of the current month)
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.