obsidian-todoist-plugin
obsidian-todoist-plugin copied to clipboard
How to fetch todoist task creation date ?
Hi there. Sorry if it isn't the right place, I looked everywhere but couldn't find anything, you're sort of my last hope now.
Following quick-add plugin todoist fetch script guide, I now have a command in my vault to gather my todoist tasks using your plugin API token and the provided quick-add script.
There is a formatting function inside that script that convert the todoist task list to a markdown format. I modified some of them to use the actual date as a created date suffix :
function formatTasksToTasksPluginTask(t) {
const todayDate = new Date().toISOString().split("T")[0]; // Get today's date in YYYY-MM-DD format
return (
t
.map(
(t) =>
(t = t.rawDatetime
? `- [ ] ${t.content} \u2795 ${todayDate} \ud83d\udcc5 ${t.rawDatetime.format(
"YYYY-MM-DD"
)}`
: `- [ ] ${t.content} \u2795 ${todayDate}`)
)
.join("\n") + "\n"
);
}
My issue is that I would like to use the createdAt property of a task, but it doesn't work, I get an incorrect date. I tried using ${t.createdAt.format("YYYY-MM-DD")} as well with no results.
As you have some experience with todoist API, do you have an idea of what might be wrong here ?
Thanks in advance !
Edit : Tried using the following modifications :
function formatTasksToTasksPluginTask(t) {
const todayDate = new Date().toISOString().split("T")[0]; // Get today's date in YYYY-MM-DD format
return (
t
.map(
(t) =>
(t = t.rawDatetime
? `- [ ] ${t.content} \u2795 ${t.createdAt.format("YYYY-MM-DD")} \ud83d\udcc5 ${t.rawDatetime.format(
"YYYY-MM-DD"
)}`
: `- [ ] ${t.content} \u2795 ${t.createdAt.format("YYYY-MM-DD")}`)
)
.join("\n") + "\n"
);
}
Ended with this error :
To be honest, I don't even get how does he manage to gather the due date of the task using t.rawDatetime, when I use console.log(t) to see the task object, it doesn't even have the property :
I see now that there is no such thing as the task creation date, even on tasks with due date :
I shall now find a way to gather it using your API I reckon.
Hi @mathisgauthey, I'm not sure where that script comes from - but its not something that I support. If you want to reverse engineer the internal data format, that's okay - but be aware it can/will break if I refactor things.
In fact, it definitely will break in the next release.