Skip to content
New 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

Include someday/maybe tasks in daily notes in the someday/maybe list #50

Merged
merged 1 commit into from
Jan 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion DemoVault/Daily Notes/2022-01-04.md
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
- [ ] Do something on this date
- [ ] Do something on this date
- [ ] Do something in 2099 [due:: 2099-01-01]
- [ ] Do something, some day #someday
26 changes: 26 additions & 0 deletions model/TodoParser.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,29 @@ test('parsing a todo in a daily notes file', async () => {
expect(todo.actionDate.month).toEqual(DateTime.now().month);
expect(todo.actionDate.year).toEqual(DateTime.now().year);
});

test('parsing a todo in a daily notes file with a due date', async () => {
const contents = `- [ ] This is something that needs doing #2022-04-01`;
const todos = await todoParser.parseTasks('/Daily Notes/today.md', contents);
const todo = todos[0];
expect(todo.actionDate.day).toEqual(1);
expect(todo.actionDate.month).toEqual(4);
expect(todo.actionDate.year).toEqual(2022);
});

test('parsing a todo in a daily notes file tagged as someday/maybe', async () => {
const contents = `- [ ] This is something that needs doing #someday`;
const todos = await todoParser.parseTasks('/Daily Notes/today.md', contents);
const todo = todos[0];
expect(todo.actionDate).toBeUndefined();
expect(todo.isSomedayMaybeNote).toEqual(true);
});

test('parsing an outstanding todo with a specific action date and a someday/maybe tag', async () => {
const contents = `- [ ] This is something that needs doing #2021-02-16 #someday`;
const todos = await todoParser.parseTasks('/', contents);
const todo = todos[0];
expect(todo.status).toEqual(TodoItemStatus.Todo);
expect(todo.actionDate).toBeUndefined();
expect(todo.isSomedayMaybeNote).toEqual(true);
});
5 changes: 3 additions & 2 deletions model/TodoParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,16 @@ export class TodoParser {
const actionDate = this.parseDueDate(description, filePath);
const descriptionWithoutDate = this.dateParser.removeDate(description);
const somedayPattern = /#(someday)/g;
const isSomedayMaybeTask = description.match(somedayPattern) != null;

return new TodoItem(
status,
descriptionWithoutDate,
description.match(somedayPattern) != null,
isSomedayMaybeTask,
filePath,
(entry.index ?? 0) + todoItemOffset,
entry[0].length - todoItemOffset,
actionDate,
!isSomedayMaybeTask ? actionDate : undefined,
);
}

Expand Down