obsidian-todoist-plugin icon indicating copy to clipboard operation
obsidian-todoist-plugin copied to clipboard

How to fetch todoist task creation date ?

Open mathisgauthey opened this issue 2 years ago • 1 comments

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 : image

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 : image

mathisgauthey avatar Aug 29 '23 22:08 mathisgauthey

I see now that there is no such thing as the task creation date, even on tasks with due date : image

I shall now find a way to gather it using your API I reckon.

mathisgauthey avatar Aug 30 '23 09:08 mathisgauthey

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.

jamiebrynes7 avatar Feb 01 '24 20:02 jamiebrynes7