YukiGasai / obsidian-google-tasks

Add Google Tasks inside Obsidian
GNU General Public License v3.0
134 stars 9 forks source link

Date displayed in obsidian is one day before the date of the google task. #9

Closed sessionsdev closed 2 years ago

sessionsdev commented 2 years ago

To reproduce:

Create a google task for tomorrow and view the task in the obsidian-google-task panel.

Expected Result: The task pane display the task under the "Tomorrow" header.

Actual Result: The task pane displays the task under the "Today" header.

This is also reproducible for dates other than today. You can confirm by creating a google tasks for the first of the next month. obsidian google task pane will display the task as the day before the actual due date of the task.

sessionsdev commented 2 years ago

Evidence:

Note it is currently Saturday, September 17, 2022 2:52:39 PM (UTC) at the time of writing this comment.

API response for the testing task: { "kind": "tasks#task", "id": "WUhxZmljalN0MFBpRFZTWQ", "etag": "\"MTI3MzUxODM0MQ\"", "title": "DUE TOMORROW", "updated": "2022-09-17T14:44:21.000Z", "selfLink": "https://www.googleapis.com/tasks/v1/lists/cXdTZEVFREoxT090QVR2VQ/tasks/WUhxZmljalN0MFBpRFZTWQ", "position": "00000000000000000000", "status": "needsAction", "due": "2022-09-18T00:00:00.000Z", "links": [] }

Screen cap of the obsidian pane:

Capture

YukiGasai commented 2 years ago

grafik

I can't reproduce this problem, but I assume it's a timezone or daylight saving problem.

Please check out the new version.

sessionsdev commented 2 years ago

@YukiGasai

No change after the update and an obsidian restart.

I doubled checked the GETs and POSTs that the plugin is sending and everything looks fine to me. Google tasks looks fine to me. Data is all good.

Just seems to be a rendering problem. Every task is listed as due one day earlier. I have a task for 8/1/2023, for example, but the obsidian plugin renders it as due 7/31/23. This happens whether creating the task from obsidian, or directly in google tasks

I have eliminated these as potential causes:

  1. data discrepancy in api responses.
  2. Conflicts with other community plugins.
  3. Conflicts with themes, appearance settings or css.
sessionsdev commented 2 years ago

Sorry, did not mean to close. Re-opening.

YukiGasai commented 2 years ago

I checked again and can't reproduce the problem. That sucks :(. Could you please give me your timezone, country? Does your country have daylight saving times? On what time of day are you using the plugin?

sessionsdev commented 2 years ago

@YukiGasai

I am in USA, currently in EDT timezone (UTC−04:00)

I am using the plugin multiple times per day. I've done multiple tests, with tasks due at all different times of day, created via different clients. Moved tasks, edited times, etc. etc.

No matter what. The due date returned in the obsidian pane is one day before the actual due date. This is happening for tasks far into the future as well. All tasks in all lists. This is happening on mac (whatever latest OS), windows 10, and linux (ubuntu) (app image) I have exhausted all tests that I can think of. lol

I am on latest Obsidian Insider build (0.16.3), btw. Sorry, should have mentioned that earlier. I don't see anything in the release notes that would conflict with your code here though.

YukiGasai commented 2 years ago

With your timezone, I was able to reproduce the bug. Please check out the new version and check if it worked for you.

sessionsdev commented 2 years ago

Hey @YukiGasai It seems to be mostly working as expected. Future dates are displaying the correct date. And n+2 weeks days is displaying as the correct day of the week. (e.g. "Wednesday"). However, "Yesterday", "Today" and "Tomorrow" is one day behind. (i.e. A Task due today, is displayed as "Yesterday).

image

sessionsdev commented 2 years ago

Screen cap was taken at 23:50 DST on Sunday. (North East USA)

UTC is already Monday. So looks like view is rendering as if it's already Monday for me, so task due today (sunday), is displayed as due yesterday,

sessionsdev commented 2 years ago

Some quick googling, looks like you can do something like:

var stillUtc = moment.utc(date).toDate();
var local = moment(stillUtc).local().format('YYYY-MM-DD HH:mm:ss');

https://stackoverflow.com/a/32540840

YukiGasai commented 2 years ago

@sessionsdev Thank you for keeping up and not giving up on the plugin. I added the code from the stack overflow post and updated the date, so it's not directly at midnight, to avoid further problems.

sessionsdev commented 2 years ago

@YukiGasai Of course! I'm hopeful the plugin can improve my workflow. If my JS was better, I would have offered to contribute. :)

However, I am now unable to update the plugin via the obsidian app. Just gives me a "Failed To Install" message. This is after a full uninstall and obsidian restart.

YukiGasai commented 2 years ago

@sessionsdev

I forgot to create a new release, please check again.

sessionsdev commented 2 years ago

Hey @YukiGasai

There is one minor bug left, I think. But this is mostly working as expected.

When creating a new task with the plugin, it will still display the due date incorrectly UNTIL it refreshes and fetched the data from google again.

Screen Shot 2022-09-29 at 12 35 37 PM

Screen Shot 2022-09-29 at 12 38 50 PM

YukiGasai commented 2 years ago

Sorry, closed automatically. Please check if it worked for you.

sessionsdev commented 2 years ago

Excellent! Everything working as expected. Closing this issue as resolved.

Thanks for your commitment to the plugin.