obsidian-tasks
obsidian-tasks copied to clipboard
Add support for more abbreviations - startOf(PERIOD) and endOf(PERIOD) literals - to autocompletion
⚠️ Please check that this feature request hasn't been suggested before.
- [X] I searched previous Ideas in Discussions didn't find any similar feature requests.
- [X] I searched previous Issues didn't find any similar feature requests.
- [X] I am only requesting a single feature. Multiple changes should be split into individual requests, with links between them.
- [X] I believe my requested feature will be generally applicable to other users, not just me: it is not uniquely tied to my personal workflow.
🔖 Feature description
- Add support for literals for inputting dates faster in the task dialog
- Add support for literals for inputting dates faster in the task auto-suggestion
The literals would be as follow :
- date(eow) | A date representing the end of the current week
- date(som) | A date representing the start of the current month
- date(eom) | A date representing the end of the current month
- date(soy) | A date representing the start of the current year
- date(eoy) | A date representing the end of the current year
Once the simple literals are added, one could add support for :
- Adding support for literals like
start of PERIOD
andend of PERIOD
. PERIOD being a week, month, quarter or year.
✔️ Solution
I don't know about the technical aspect of such a thing, but it was done in dataview and might even be part of momentjs or something.
❓ Alternatives
Auto-complete while typing something entirely like :
- end of year instead of eoy
- start of week istead of sow
📝 Additional Context
N / A
Thanks for the suggestion.
I'm not sure that I fully understand the suggestion.
Does date(eow)
mean that the user is required to type that text in full? Or what doe the date(
and )
mean?
Thanks for the suggestion.
I'm not sure that I fully understand the suggestion.
Does
date(eow)
mean that the user is required to type that text in full? Or what doe thedate(
and)
mean?
The idea would be that while typing inside the task dialog inside the due date box, writing eow
would autocomplete to the end of week
date. Same thing while on a markdown document with the task auto-completion feature that must share the same code I reckon.
For now, I can "only" type today
, td
, tomorrow
, tmr
, in 10 days
, and so on.
I think it could be a nice addition for fast input of date.
But one could also use something like end of feb
to add a task to the last day of February for instance.
Hence the scope of this FR is twofold :
- Adding support for dataview like literals for faster input in current periods :
sow
,eow
,som
, etc. - Adding support for literals like
start of PERIOD
andend of PERIOD
. PERIOD being a week, month, quarter or year.
Same thing while on a markdown document with the task auto-completion feature that must share the same code I reckon.
I checked, and you are correct, they do use the same code:
https://github.com/obsidian-tasks-group/obsidian-tasks/blob/main/src/DateAbbreviations.ts https://github.com/obsidian-tasks-group/obsidian-tasks/blob/main/tests/DateAbbreviations.test.ts
The abbreviations are documented here:
https://publish.obsidian.md/tasks/Getting+Started/Create+or+edit+Task#Date+abbreviations
I don't think I noticed that - I can't see the abbreviations mentioned in https://publish.obsidian.md/tasks/Getting+Started/Auto-Suggest
I'll add the Help Wanted label to this. It seems like a reasonably localised area of code for contributions to.
Same thing while on a markdown document with the task auto-completion feature that must share the same code I reckon.
I checked, and you are correct, they do use the same code:
https://github.com/obsidian-tasks-group/obsidian-tasks/blob/main/src/DateAbbreviations.ts https://github.com/obsidian-tasks-group/obsidian-tasks/blob/main/tests/DateAbbreviations.test.ts
The abbreviations are documented here:
https://publish.obsidian.md/tasks/Getting+Started/Create+or+edit+Task#Date+abbreviations
I don't think I noticed that - I can't see the abbreviations mentioned in https://publish.obsidian.md/tasks/Getting+Started/Auto-Suggest
I'll add the Help Wanted label to this. It seems like a reasonably localised area of code for contributions to.
You know what, I think I'd like to take care of this one. I'll finish with the basics soon enough and will be glad to take a throughout look at this.
Just a small update here.
I found that indeed, startOf('TIME')
and endOf('TIME')
are momentjs functions.
I'm just looking at the codebase to find the place where dates are changed so that I can add these.
Edit :
It seems like the two files I'll need to look into are DateParser.ts
and DateRange.ts
.
Then add abbreviations in DateAbbreviations.ts
.
Probably will need to add modifications to Suggestor.ts
as well for editing tasks on the go.
That'll be great, it's my next work, so I'll get to it after Christmas o/
I think it may be simpler than that.
The current abbreviations in DateAbbreviations.ts
appear to not need DateParser.ts
and DateRange.ts
at all...
They expand short strings like td
into text that would already be recognised if the user typed it by hand (like today
) - and then the expanded text is processed just as though the user had typed the whole thing.
If I'm wrong and it looks more complicated than that, may I suggest that you and I have a session pairing on it? It would likely save us both quite a lot of time...
I am wrong!
I think it may be simpler than that.
The current abbreviations in
DateAbbreviations.ts
appear to not needDateParser.ts
andDateRange.ts
at all...They expand short strings like
td
into text that would already be recognised if the user typed it by hand (liketoday
) - and then the expanded text is processed just as though the user had typed the whole thing.If I'm wrong and it looks more complicated than that, may I suggest that you and I have a session pairing on it? It would likely save us both quite a lot of time...
There's that and I've done it on my fork. The next part would be to make this abbreviation work while typing markdown tasks (Suggestor.ts
is where I'll look) and to auto-match a date with text such as end of month
=> 2023-12-31
. I see that there's already some kind of end of february
and the likes, so I don't intend to be redundant and will look after what's missing and what's already there in DateParser.ts
and DateRange.ts
.
But sure, let's see that during a session someday, no rush I'm just learning around for now o/
Hi @mathisgauthey, how are you getting on with this?
I'm asking as I have in progress a date-picker widget, which I am testing in my own fork.
It's looking rather promising, and is a lot more flexible than typing abbreviations.
So I am inclined to think that the date-picker is a better use of developer time than this???
Oh wait, this is also talking about use of the abbreviations in Auto-Suggest as well as in the Edit Task modal...
That complications things a bit, as there isn't a likely to be a date-picker in Auto-Suggest...
Oh wait, this is also talking about use of the abbreviations in Auto-Suggest as well as in the Edit Task modal...
That complications things a bit, as there isn't a likely to be a date-picker in Auto-Suggest...
Hey there ! Yes indeed I was mainly looking at some autocomplete feature to type dates faster using sow
= start of week
for example !
But I did not do anything so don't bother with merge issues 😅
Hey there ! Yes indeed I was mainly looking at some autocomplete feature to type dates faster using
sow
=start of week
for example !
Yes, I forgot that... I was thinking of this as purely an Edit Task Modal thing...
But I did not do anything so don't bother with merge issues 😅
Hahah, it was more about whether to just close the ticket!
But I'll leave it open for now.