blacksmithgu / obsidian-dataview

A data index and query language over Markdown files, for https://obsidian.md/.
https://blacksmithgu.github.io/obsidian-dataview/
MIT License
6.97k stars 409 forks source link

Honour date format when using Emoji completion #1582

Open holroy opened 1 year ago

holroy commented 1 year ago

If you don't enable emoji completion, you can set the completion date format, but if you enable them the completion date is locked to yyyy-MM-dd, and it is clearly stated that this is the case in the settings pane.

However, would it be possible to change this to allow for the completion date format to be honoured even when emoji completion is selected?

This would allow for a user defined time precision on when the task was completed. Like if you complete multiple tasks a day, you could use a format including hours and minutes, and if you just want to know the week or month, you could select a date/time format accordingly.

s-blu commented 1 year ago

I had hoped that this is an easy win but I was wrong, sadly. Enabling and using the custom date format for the first check is straight forward, the problem is when you uncheck tasks again: dataview tries to remove the emoji shorthand and due to the nature of the emoji shorthands (i.e. absent of the brackets) it needs to know very exactly how the possible value of the field looks like in order to be able to search for it via regex, see

https://github.com/blacksmithgu/obsidian-dataview/blob/a1588ed63c28555220bb32cb820a324fca3ca2e4/src/data-import/inline-field.ts#L182-L186 https://github.com/blacksmithgu/obsidian-dataview/blob/a1588ed63c28555220bb32cb820a324fca3ca2e4/src/data-import/inline-field.ts#L200

It would be possible to introduce a second set of regular expressions and give you another switch to decide if you want to save times alongside your emoji shorthand, but freely choosing a date format seems very tricky.

holroy commented 1 year ago

I see... The general solution to this would be to actually parse the date format, and then generate the regex based upon the date format, but that is not a trivial solution, not if you allow the full date format at least.

Another option could be to allow for a few predefined date formats, which had preset regex parts already defined. That could possibly work, but would it be a nuisance to have since somebody would keep asking for new formats? Not sure...

Oh well, don't use too much time on this. It would be nice to have, but I'll live just nicely without it as well. So look into it if you have the energy and drive to do so, but don't wear yourself out chasing this one. Thanks for all the other work you've already done, and keep doing. Dataview is a very useful plugin for geeks like me!