schemar / obsidian-tasks Public
generated from obsidianmd/obsidian-sample-pluginNew issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
support custom date format #296
Conversation
|
+1 up vote for this feature |
|
+1 |
2 similar comments
|
+1 |
|
+1 |
|
Thank you @shabegom I will do a proper review when I find the time. Until then, can you please:
Thank you for the effort! |
LMK if you have any other feedback! That test allowing the emoji in the description got me good! If you want me to write any tests for this feature lmk. |
|
I think you can remove the However, I can't wrap my head around a fundamental problem when allowing users to change the format of dates: what happens to all the tasks already in the vault? Their due and done dates would simply become invalid and instead be part of the description now. In your current implementation this also means the parser stops parsing metadata from the end of the task line and thus the recurrence rule would be lost as well. In short: just allowing users to change the format will lead to what they deem a "broken" Tasks plugin and get back to me via bug tickets. We need to consider updating all existing tasks when changing the setting. What do you think? |
|
Here's the simplest approach imo. I could add a button to the settings or a command that runs a one time conversion to any new date format specified. That way all previous tasks would get updated. it could also just auto update, but we'd need to validate the user has completed entering their new format into the field with onBlur or something... I'm not too sure about accepting any date format, it's totally doable (just don't provide a second argument to moment() and any valid dateformat will be parsed). But I think it will confuse people if they see a different format between edit and preview of the tasks. |
|
That would be a big gesture. For me, I couldn't see any problem taking
personal responsibility for changing the date format for my previously
entered tasks, given it was my choice to set the option for a date link.
…On Tue, 31 Aug 2021 at 05:23, Sam ***@***.***> wrote:
Here's the simplest approach imo. I could add a button to the settings or
a command that runs a one time conversion to any new date format specified.
That way all previous tasks would get updated. it could also just auto
update, but we'd need to validate the user has completed entering their new
format into the field with onBlur or something...
I'm not too sure about accepting any date format, it's totally doable
(just don't provide a second argument to moment() and any valid dateformat
will be parsed). But I think it will confuse people if they see a different
format between edit and preview of the tasks.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#296 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ARTR6N2SOVROSJ73DH4C3XLT7PLEJANCNFSM5CXJTPAA>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
|
|
While going down the rabbit hole to modify this plugin to be my perfect task manager I stumbled across the same problem of being able to read multiple formats. The branch I'm working on (not at all pretty enough for a PR): |
|
Hoping to see this merge already for days :-) I am also willing to migrate my tasks to the new format. |
|
I don't have time right now for private reasons. I plan to add some new things, including open PRs, to Tasks some time during October. Please be patient. I think the best solution will be to not support any format, but a number of specific formats, including links ( |
Merge branch 'schemar-main'
|
Thank you for the update @shabegom. This is next on my list. |
|
The fork is still a broken given the massive update. I'm working on it though. Totally didn't realize I opened this PR off the main branch... |
Thank you! If it is too much, I can also do it. I suspect I will do some changes after merging either way |
|
It also looks like there are some unrelated changes @shabegom |
|
Oh maybe you mean the manifest? I can change that back. That was for my own testing. Sorry! My tsserver was yelling at me about app not existing and Notice not being used...I can also revert that change if it was wrong. |
|
@schemar I'll revert those changes back today. Sorry about that. Just blindly following the linting errors. |
|
If the linter complains, it's fine to update |
|
@schemar I've reverted some of the unrelated changes and left the ones that were throwing errors. Also updated the tests in Query.test.ts. I'm getting a test failure that I don't think is related to the changes: Jest: concurrent test "Query sorting instructions sorting as {"input":"sort by status\nsort by due","output":[{"property":"status","reverse":false Let me know if there is anything else I can do to get this merge ready. Thanks! |
| tasks.map(async (task) => { | ||
| if (task.description.startsWith('![[')) { | ||
| const link = parseLinktext(task.description); | ||
| const subpath = link.subpath | ||
| .replace('#^', '') | ||
| .replace(']]', ''); | ||
| if (link) { | ||
| const file = this.app.metadataCache.getFirstLinkpathDest( | ||
| link.path.replace('![[', ''), | ||
| task.path, | ||
| ); | ||
| const content = | ||
| file && (await this.app.vault.read(file)).split('\n'); | ||
| const blocks = | ||
| file && | ||
| this.app.metadataCache.getFileCache(file)?.blocks; | ||
| const line = blocks && blocks[subpath]?.position.start.line; | ||
| if (line) { | ||
| task.description = content[line] | ||
| .split(' ^')[0] | ||
| .replace('- ', ''); | ||
| } | ||
| } | ||
| } | ||
| }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@shabegom can you please explain how this is related to the custom date format?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is so weird! This is from a totally unrelated plugin (block ref counter) and I have no idea how it made it in here. My best guess is Github Copilot suggested this code and I hit tab by accident...
I'm sorry I didn't catch this before. That's really embarrassing. can be fully deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No worries
| @@ -146,6 +172,7 @@ class QueryRenderChild extends MarkdownRenderChild { | |||
| }: { | |||
| tasks: Task[]; | |||
| content: HTMLDivElement; | |||
| app: App; | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this actually used?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't believe it is used. I missed this.
Merging into a branch. It would still help me if you replied to my questions
|
@shabegom, @TfTHacker, @GitMurf, @arminta7, @kmaustral, @PJJPtx, @jan-willi, @wenlzhang all of you upvoted or participated here or in the discussion #69. If Tasks supported a fixed list of date formats (only dates, no times), which format(s) would you require? All would have the option to be links. |
|
Thank you for your work on this project!!! Format for me: YYYY-MM-DD By the way, one of things I have done with my plugins is get the date format for daily notes page which tends to be the format used by the user in his vault. This can be easily retrieved with this library. https://github.com/liamcain/obsidian-daily-notes-interface |
This is great! Thank you! |
Incorporating and cleaning up the changes proposed in #296.
|
Please could you add the option to change the date format to DD-MM-YYYY (reverse order) to follow EU/UK regional formatting? |
Will do |
This PR adds support for:
There are two new settings added to Tasks settings modal. One allows a date format to be set which is then used during moment.format(). The other is a toggle to make dates links.
I've also updated the due and done date regex to be a bit more open. I went the easy route instead of trying to guess all the different date formats. I hope this is ok!