maxpozdeev / mytinytodo

Todo list script
157 stars 49 forks source link

Feature request: smart syntax for due date #26

Closed xenotropic closed 8 months ago

xenotropic commented 2 years ago

Hi Max,

As a person who primarily organizes their tasks by when they are due, it would be really cool if it was possible to just enter a string, somehow escaped/delimited, to set the due date in the "new task" entry field. Much like the current smart syntax for priority, but for days of the week or dates.

I think the most useful would be to use the days of the week (so adding something like "//Friday" or "#Friday" or whatever other escaping text delimiters suit your fancy), and then mytinytodo sets the due date to the next date that is that day of the week.

And maybe the same delimiter with a numeral would set it to the next date with that numeral. So like today is Feb 22, if I added "#28" to a task that would set a due date of Feb 28. If I added "#3" it would set the due date to be March 3.

Thanks for considering!

qwertfisch commented 2 years ago

This sounds a lot like the change I made several years ago for my personal MTT instances. The smart syntax is fine but needs to many characters to be really fast. Also a quick setting for the due date was missing, like you requested, so I added this feature, too. My syntax is as follows:

priority title @tag,tag,... [due date]

where priority can be a +, ++ or a - to indicate the level. The due date can be either a number that indicates, how many days in the future (or past with a negative sign) the due date is set. Or you provide a date in form of 28.4. or 28.4.2023. I used German date format, but something like ISO 8601 is also possible to add as feature.

Example: + Bread and cheese @groceries [+2] creates a task with priority +1, tag “groceries” and is due in two days.

Improvements

I did not touch the code for many years (works for me), but your suggestions about weekdays or days of month are also nice to have. It should be a consistent syntax. The pound sign # is possible, but it mostly indicates counted things. For German users I would use 28. (see the dot) for day of month, but that differs in other countries. For weekdays, a textual notation seems the best approach.

Is the enclosing in [] ok? A double slash seems also nice, fast enough to type.

The implementation is easy and you can apply a small patch to your installation (changes only one file).

xenotropic commented 2 years ago

Awesome, thank you!

German DMY dates are fine by me, including the 28. syntax. Makes more sense in this context to start with the specific. And it is what most of the world uses.

Personally I would pick leading double-slash over enclosing brackets. Slightly easier to type on mobile keyboards, to avoid having to go to special-character keyboard twice (and my mobile keyboard actually privileges forward-slash with its own key, because URLs). But either is really fine, so if enclosing brackets is what you have already and you don't want to change it, that's fine.

Weekdays would personally help me the most. I'm always telling people "I'll do that for you by [day of week]". So if I could just type in "Do foo //Tuesday" and it automatically due-dates to Tuesday that would be wonderful.

qwertfisch commented 2 years ago

Today I found the time to implement the changes to smart syntax. My tests show no remaining bugs, but if you find one, please add a comment here. Using double-slash syntax is indeed easier to type, even on a regular keyboard. So I changed it to //.

A date like 28. is now interpreted as the 28th of the current month or, if today is the 28th or later, the next month (and possibly next year when it is December). Specifying day and month gives the same: 28.4. is April 28th this or next year, depending on current date. //Tue or //Tuesday will be interpreted as next Tuesday (PHP seems to interpret at least these forms automatically). If today is already Tuesday, I will add a week. PHP would return the current day, which seems a bit pointless – but you could change this behaviour by commenting the line after “On same weekday …”. The complete syntax now is:

priority title @tag1,tag2,another tag,… //duedate You can omit each part, but not change their order. Everything after the last @ is interpreted as a list of tags (until // occurs, of course).

Apply the attached patch with git apply ajax.patch.txt in the Git repository on branch v1.6.x. (tag v1.6.8) – Or you simply copy the ajax.php (from my Gitea) over your current installation, if there are no additional changes by yourself. The last section of the patch (for prepare_duedate) fixes a bug in the due date calculation regarding daylight saving time. (I should add a pull request for this seperately …)

xenotropic commented 2 years ago

Excellent, I just entered my first // style due date task, much faster. Something I'll appreciate pretty much every day. Thanks!

xenotropic commented 2 years ago

One bug is that adding "//today" makes the deadline in one week, which is not expected behavior.

With the “On same weekday …” line commented out, it works.

It would be kinda neat to have the week-from-today functionality (i.e., "//wed" meaning "in seven days" if today is Wednesday). But it is also good/coherent functionality with that line commented out.

qwertfisch commented 2 years ago

Sorry, I did not test for “today”. I changed the code: only the first three letters are compared with the current day of week. This works now with “today”. Do you want to enter other forms of date strings like "next monday"? I have changed the regex so that a date cannot contain spaces (which allows me to have // for other means than dates like URLs), but if you like other English text dates, I would think a bit harder about the filtering.

To download, see the same link as before (eventually force reload in browser) for ajax.php.

Also you can get today’s date faster by using //0 (means +0 days), or just //, which will expand to the current date. Additionally, with //7 you can set a due date in exactly one week.

aleksej-kuznecow commented 1 year ago

Hello Max. Is it possible to vote for this issue? It looks like realy helpful in GTD and tasks planning process. And it realy will close the topic of smart parsing of a task

xenotropic commented 1 year ago

FWIW I have been using @qwertfisch 's code for a year now, works great, so at least on the basis of functionality (I haven't reviewed the code carefully), perhaps worth considering merging it into master

chupchupchup commented 1 year ago

It was a brilliant idea!!! Unfortunately, the code seems obsolete, because the ajax.php file no longer exists in the current version and does not work if put in the root folder, but it could work like the three plugins: Custom CSS , Notifications, Updates... when do you think? Or do you have another working quick fix to apply your solution?

maxpozdeev commented 1 year ago

I'll try to add a possibility to create an extension to use own smart syntax parsers. Planned in the next v1.8. Hope, the beta will be available till the 1st of October.

maxpozdeev commented 8 months ago

Example of extension to create custom smart syntax. SmartSyntaxExample.zip