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

Handling of org-gcal-local-timezone incorrect #134

Open
wrn opened this issue Sep 24, 2021 · 1 comment
Open

Handling of org-gcal-local-timezone incorrect #134

wrn opened this issue Sep 24, 2021 · 1 comment

Comments

@wrn
Copy link

wrn commented Sep 24, 2021

Just realized I filed this ticket on the wrong branch. Re-filed to kidd/org-gcal.el. Not sure how to delete an issue.

I am very excited to try out org-gcal, and was puzzled that the timestamps for my calendar events are sometimes right, sometimes wrong. With some digging, I found the issue is this:

  1. For unknown reason, Google calendar API does not returns timestamps in consistent timezones. At least that is the case for my family shared calendar (a build in feature by Google). Family calendar timezone is fixed to UTC, although when an event is created, that event is created with default local time zone (US eastern time for me). I verified my events are created correctly in US eastern time. But when org-cal fetch them, for some events, the time is returned in eastern time, but for some other events the time is returned in UTC time (the time itself is always correct, just represented in different time zones)

  2. It becomes a problem for the following function
    (defun org-gcal--convert-time-to-local-timezone (date-time local-timezone)
    (if (and date-time
    local-timezone)
    (format-time-string "%Y-%m-%dT%H:%M:%S%z" (parse-iso8601-time-string date-time) local-timezone)
    date-time))

When org-gcal-local-timezone is set to nil, date-time is directly returned, hence sometimes it is wrong (for those in UTC time).

  1. But, if we set org-gcal-local-timezone to my local time zone, it also poses some issues:
  1. I found the time zone string is very finicky for format-time-string. For example "America/New York" does not work properly on either Windows or Linux. (current-time-zone) returned from Emacs does not work on Windows but works for Linux. (-14400 "EDT") works on both. Such a pain.
  2. When local time zone is set to nil, we have the nice behavior that the time will be automatically set to the time zone for that particular date. Time zone is not only determined by location, but also date, because of day light savings time.
    For example (note the different time zone in the result):
    (format-time-string "%Y-%m-%dT%H:%M:%S%z" (parse-iso8601-time-string "2021-09-29T12:15:00-04:00") nil) => "2021-09-29T12:15:00-0400"
    (format-time-string "%Y-%m-%dT%H:%M:%S%z" (parse-iso8601-time-string "2021-12-29T12:15:00-04:00") nil) => "2021-12-29T11:15:00-0500"
  1. So it seems to me the best option is to change the function org-gcal--convert-time-to-local-timezone to:
    (defun org-gcal--convert-time-to-local-timezone (date-time local-timezone)
    (format-time-string "%Y-%m-%dT%H:%M:%S%z" (parse-iso8601-time-string date-time) local-timezone))
    This will make the out-of-box default behavior work for 99% of us.

The above was tested on both Windows and Linux, Emacs 26.3.

Thanks for this great package.

@telotortium
Copy link

@myuhe please close this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants