kidd / org-gcal.el

Org sync with Google Calendar. (active maintained project as of 2019-11-06)
439 stars 47 forks source link

Add org-gcal-local-timezone to respect timezone #118

Closed tendant closed 3 years ago

tendant commented 3 years ago

Trying to fix #48 by adding org-gcal-local-timezone for fetching events.

telotortium commented 3 years ago

Thanks for the PR! Please do the following:

jasoncorso commented 3 years ago

Hi Everyone, what's the status of this PR? It's a really important fix. Thanks for the hard work to support org-gcal.

telotortium commented 3 years ago

@tendant Can you write some tests in test/org-gcal-test.el? I've just set up CI, so you should be able to push to the PR and see your tests run (after you rebase on the latest master).

tendant commented 3 years ago

Added test cases, but below test cases are fine in local testing, but they will fail GitHub CI build. So I have commented out them for now.

  (should (equal
           (convert-time-to-local-timezone "2021-03-03T11:30:00-08:00" "Europe/Oslo")
           "2021-03-03T20:30:00+0100"))
  (should (equal
           (convert-time-to-local-timezone "2021-03-03T11:30:00-08:00" "America/New_York")
           "2021-03-03T14:30:00-0500"))
  (should (equal
           (convert-time-to-local-timezone "2021-03-03T11:30:00-08:00" "America/Los_Angeles")
           "2021-03-03T11:30:00-0800"))
  (should (equal
           (convert-time-to-local-timezone "2021-03-03T11:30:00-08:00" "Asia/Shanghai")
           "2021-03-04T03:30:00+0800"))
telotortium commented 3 years ago

Please rename convert-time-to-local-timezone to org-gcal--convert-time-to-local-timezone.

telotortium commented 3 years ago

Interesting that several cases in the test fail - I wonder if it's a bug in the current snapshot edition.

tendant commented 3 years ago

It might because the OS running test doesn't have timezone information, that's the only part which might depended on the OS.

telotortium commented 3 years ago

Yeah maybe. Otherwise it looks good. I presume you've tested this manually against the actual Google Calendar API?

tendant commented 3 years ago

Yes. I did.

It works fine for me with time zone "America/Los_Angeles".

Testing steps:

  1. Local and Google Calendar timezone: "America/Los_Angeles"
  2. Create event entry:
    * test 
    SCHEDULED: <2021-03-04 Thu 10:00>
  3. Run "org-gcal-post-at-point"
  4. Event show up correctly in Google calendar for "2021-03-04 Thu 10:00"
  5. Delete event in org file
  6. Run "org-gcal-fetch", Test event show up in org file again.
    * test
    :PROPERTIES:
    :ETag:     ...
    ...
    :END:
    :org-gcal:
    <2021-03-04 Thu 10:00>
    :END:
telotortium commented 3 years ago

Thanks for the PR!