lfos / calcurse

A text-based calendar and scheduling application
https://calcurse.org
BSD 2-Clause "Simplified" License
964 stars 95 forks source link

Imported calendar times an hour ahead. #430

Open cookEbox opened 2 years ago

cookEbox commented 2 years ago

Using calcurse 4.8.0

When I import a calendar appointment using calcurse -i, the time comes 1 hour later than it should be. I am in the UK and its British Summer Time (UTC +1).

Here is the start of the calendar file (other parts has other people private contact details in it so this is all i can share).

BEGIN:VCALENDAR METHOD:REQUEST PRODID:Microsoft Exchange Server 2010 VERSION:2.0 BEGIN:VTIMEZONE TZID:GMT Standard Time BEGIN:STANDARD DTSTART:16010101T020000 TZOFFSETFROM:+0100 TZOFFSETTO:+0000 RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=-1SU;BYMONTH=10 END:STANDARD BEGIN:DAYLIGHT DTSTART:16010101T010000 TZOFFSETFROM:+0000 TZOFFSETTO:+0100 RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=-1SU;BYMONTH=3 END:DAYLIGHT END:VTIMEZONE

Thanks.

texel-sensei commented 1 year ago

I had the same issue, except it was 2 hours ahead (but I'm living in UTC+2), so the issue seems to be with the timezone handling.

This is an excerpt of the ical file I used, one thing I noticed was that it also was created by "Microsoft Exchange Server 2010"

BEGIN:VCALENDAR
METHOD:REQUEST
PRODID:Microsoft Exchange Server 2010
VERSION:2.0
BEGIN:VTIMEZONE
TZID:W. Europe Standard Time
BEGIN:STANDARD
DTSTART:16010101T030000
TZOFFSETFROM:+0200
TZOFFSETTO:+0100
RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=-1SU;BYMONTH=10
END:STANDARD
BEGIN:DAYLIGHT
DTSTART:16010101T020000
TZOFFSETFROM:+0100
TZOFFSETTO:+0200
RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=-1SU;BYMONTH=3
END:DAYLIGHT
END:VTIMEZONE
BEGIN:VEVENT
[...]
SUMMARY;LANGUAGE=de-DE:********
DTSTART;TZID=W. Europe Standard Time:20220922T130000
DTEND;TZID=W. Europe Standard Time:20220922T140000
CLASS:PUBLIC
PRIORITY:5
DTSTAMP:20220915T125156Z
TRANSP:OPAQUE
STATUS:CONFIRMED
SEQUENCE:0
LOCATION;LANGUAGE=de-DE:Microsoft Teams-Besprechung

In Outlook I could import this file with the correct time.

bitstreamout commented 1 year ago

Same issue here and I've set and exported LANG to de_DE.UTF-8 to have correct locale (aka LC_TIME)

tpapastylianou commented 9 months ago

Just chiming in about the same issue. Importing an .ics file 'published' via outlook web; time appears one hour later on calcurse. Current timezone in UK is BST (UTC+1).

I do note that the card generated from outlook marks the timezone as

DTSTART;TZID=GMT Standard Time:20231011T020000
DTEND;TZID=GMT Standard Time:20231011T023000

rather than BST explicitly. In fact, when you create the event on Outlook, it is indeed the case that you don't have an option to select BST (UTC+1); you can only select "GMT (UTC+0" ... but then outlook inteprets it correctly as BST when it comes to display the event (and any alarms).

So in theory, if calcurse interprets the time as GMT to begin with, and then the system clock adds the BST difference on top, then it's possible that calcurse is doing nothing wrong here, and the stupidity is exclusively on Outlook's side. However, obviously, I would assume that importing from outlook is something a lot of calcurse users will want to do, so perhaps this may end up yet another if (Microsoft) { do_regrettable_acrobatics(); } case yet again, just like the good-old Internet Explorer days ... :)

Having said that, the lack of timezone support by calcurse is an issue...

tpapastylianou commented 9 months ago

Just adding, I noticed this issue: https://github.com/lfos/calcurse/issues/329#issuecomment-953997786

I tried swapping "GMT Standard Time" to "Europe/London" directly in the imported .ics file, and can confirm that this resulted in the right 'local' time being shown. Therefore these two issues are linked.

tpapastylianou commented 9 months ago

The solutions in #329 didn't quite work for me (they worked on occasion but not always), so I created my own, which seems to work reliably. The main difference is that instead of grepping-and-double-sed-ding, I converted the table by hand into a bash array which contains only the relevant entries, and then used this to perform straightforward sed replacements as needed (only on DTSTART / DTEND elements)

This assumes your .ics file was downloaded as /tmp/calendar.ics, and will generate a /tmp/calendar_corrected.ics file that you can import. Adapt for your own scripts as appropriate.

PS. My original, fuller script, which differs from the one below, also downloads my published outlook .ics file into /tmp/calendar.ics in the first place, and then completely resets my calendar and imports this into calcurse. But I haven't shown this here to prevent people accidentally running it blindly and getting errors about broken urls, or accidentally resetting their database if this is not something they intended to do.

#!/bin/bash

declare -A TIMEZONES=(
  ["Dateline Standard Time"]="Etc/GMT+12"
  ["UTC-11"]="Etc/GMT+11"
  ["Aleutian Standard Time"]="America/Adak"
  ["Hawaiian Standard Time"]="Pacific/Honolulu"
  ["Marquesas Standard Time"]="Pacific/Marquesas"
  ["Alaskan Standard Time"]="America/Anchorage"
  ["UTC-09"]="Etc/GMT+9"
  ["Pacific Standard Time (Mexico)"]="America/Tijuana"
  ["UTC-08"]="Etc/GMT+8"
  ["Pacific Standard Time"]="America/Los_Angeles"
  ["US Mountain Standard Time"]="America/Phoenix"
  ["Mountain Standard Time (Mexico)"]="America/Mazatlan"
  ["Mountain Standard Time"]="America/Denver"
  ["Yukon Standard Time"]="America/Whitehorse"
  ["Central America Standard Time"]="America/Guatemala"
  ["Central Standard Time"]="America/Chicago"
  ["Easter Island Standard Time"]="Pacific/Easter"
  ["Central Standard Time (Mexico)"]="America/Mexico_City"
  ["Canada Central Standard Time"]="America/Regina"
  ["SA Pacific Standard Time"]="America/Bogota"
  ["Eastern Standard Time (Mexico)"]="America/Cancun"
  ["Eastern Standard Time"]="America/New_York"
  ["Haiti Standard Time"]="America/Port-au-Prince"
  ["Cuba Standard Time"]="America/Havana"
  ["US Eastern Standard Time"]="America/Indianapolis"
  ["Turks And Caicos Standard Time"]="America/Grand_Turk"
  ["Paraguay Standard Time"]="America/Asuncion"
  ["Atlantic Standard Time"]="America/Halifax"
  ["Venezuela Standard Time"]="America/Caracas"
  ["Central Brazilian Standard Time"]="America/Cuiaba"
  ["SA Western Standard Time"]="America/La_Paz"
  ["Pacific SA Standard Time"]="America/Santiago"
  ["Newfoundland Standard Time"]="America/St_Johns"
  ["Tocantins Standard Time"]="America/Araguaina"
  ["E. South America Standard Time"]="America/Sao_Paulo"
  ["SA Eastern Standard Time"]="America/Cayenne"
  ["Argentina Standard Time"]="America/Buenos_Aires"
  ["Greenland Standard Time"]="America/Godthab"
  ["Montevideo Standard Time"]="America/Montevideo"
  ["Magallanes Standard Time"]="America/Punta_Arenas"
  ["Saint Pierre Standard Time"]="America/Miquelon"
  ["Bahia Standard Time"]="America/Bahia"
  ["UTC-02"]="Etc/GMT+2"
  ["Azores Standard Time"]="Atlantic/Azores"
  ["Cape Verde Standard Time"]="Atlantic/Cape_Verde"
  ["UTC"]="Etc/UTC"
  ["GMT Standard Time"]="Europe/London"
  ["Greenwich Standard Time"]="Atlantic/Reykjavik"
  ["Sao Tome Standard Time"]="Africa/Sao_Tome"
  ["Morocco Standard Time"]="Africa/Casablanca"
  ["W. Europe Standard Time"]="Europe/Berlin"
  ["Central Europe Standard Time"]="Europe/Budapest"
  ["Romance Standard Time"]="Europe/Paris"
  ["Central European Standard Time"]="Europe/Warsaw"
  ["W. Central Africa Standard Time"]="Africa/Lagos"
  ["Jordan Standard Time"]="Asia/Amman"
  ["GTB Standard Time"]="Europe/Bucharest"
  ["Middle East Standard Time"]="Asia/Beirut"
  ["Egypt Standard Time"]="Africa/Cairo"
  ["E. Europe Standard Time"]="Europe/Chisinau"
  ["Syria Standard Time"]="Asia/Damascus"
  ["West Bank Standard Time"]="Asia/Hebron"
  ["South Africa Standard Time"]="Africa/Johannesburg"
  ["FLE Standard Time"]="Europe/Kiev"
  ["Israel Standard Time"]="Asia/Jerusalem"
  ["South Sudan Standard Time"]="Africa/Juba"
  ["Kaliningrad Standard Time"]="Europe/Kaliningrad"
  ["Sudan Standard Time"]="Africa/Khartoum"
  ["Libya Standard Time"]="Africa/Tripoli"
  ["Namibia Standard Time"]="Africa/Windhoek"
  ["Arabic Standard Time"]="Asia/Baghdad"
  ["Turkey Standard Time"]="Europe/Istanbul"
  ["Arab Standard Time"]="Asia/Riyadh"
  ["Belarus Standard Time"]="Europe/Minsk"
  ["Russian Standard Time"]="Europe/Moscow"
  ["E. Africa Standard Time"]="Africa/Nairobi"
  ["Iran Standard Time"]="Asia/Tehran"
  ["Arabian Standard Time"]="Asia/Dubai"
  ["Astrakhan Standard Time"]="Europe/Astrakhan"
  ["Azerbaijan Standard Time"]="Asia/Baku"
  ["Russia Time Zone 3"]="Europe/Samara"
  ["Mauritius Standard Time"]="Indian/Mauritius"
  ["Saratov Standard Time"]="Europe/Saratov"
  ["Georgian Standard Time"]="Asia/Tbilisi"
  ["Volgograd Standard Time"]="Europe/Volgograd"
  ["Caucasus Standard Time"]="Asia/Yerevan"
  ["Afghanistan Standard Time"]="Asia/Kabul"
  ["West Asia Standard Time"]="Asia/Tashkent"
  ["Ekaterinburg Standard Time"]="Asia/Yekaterinburg"
  ["Pakistan Standard Time"]="Asia/Karachi"
  ["Qyzylorda Standard Time"]="Asia/Qyzylorda"
  ["India Standard Time"]="Asia/Calcutta"
  ["Sri Lanka Standard Time"]="Asia/Colombo"
  ["Nepal Standard Time"]="Asia/Katmandu"
  ["Central Asia Standard Time"]="Asia/Almaty"
  ["Bangladesh Standard Time"]="Asia/Dhaka"
  ["Omsk Standard Time"]="Asia/Omsk"
  ["Myanmar Standard Time"]="Asia/Rangoon"
  ["SE Asia Standard Time"]="Asia/Bangkok"
  ["Altai Standard Time"]="Asia/Barnaul"
  ["W. Mongolia Standard Time"]="Asia/Hovd"
  ["North Asia Standard Time"]="Asia/Krasnoyarsk"
  ["N. Central Asia Standard Time"]="Asia/Novosibirsk"
  ["Tomsk Standard Time"]="Asia/Tomsk"
  ["China Standard Time"]="Asia/Shanghai"
  ["North Asia East Standard Time"]="Asia/Irkutsk"
  ["Singapore Standard Time"]="Asia/Singapore"
  ["W. Australia Standard Time"]="Australia/Perth"
  ["Taipei Standard Time"]="Asia/Taipei"
  ["Ulaanbaatar Standard Time"]="Asia/Ulaanbaatar"
  ["Aus Central W. Standard Time"]="Australia/Eucla"
  ["Transbaikal Standard Time"]="Asia/Chita"
  ["Tokyo Standard Time"]="Asia/Tokyo"
  ["North Korea Standard Time"]="Asia/Pyongyang"
  ["Korea Standard Time"]="Asia/Seoul"
  ["Yakutsk Standard Time"]="Asia/Yakutsk"
  ["Cen. Australia Standard Time"]="Australia/Adelaide"
  ["AUS Central Standard Time"]="Australia/Darwin"
  ["E. Australia Standard Time"]="Australia/Brisbane"
  ["AUS Eastern Standard Time"]="Australia/Sydney"
  ["West Pacific Standard Time"]="Pacific/Port_Moresby"
  ["Tasmania Standard Time"]="Australia/Hobart"
  ["Vladivostok Standard Time"]="Asia/Vladivostok"
  ["Lord Howe Standard Time"]="Australia/Lord_Howe"
  ["Bougainville Standard Time"]="Pacific/Bougainville"
  ["Russia Time Zone 10"]="Asia/Srednekolymsk"
  ["Magadan Standard Time"]="Asia/Magadan"
  ["Norfolk Standard Time"]="Pacific/Norfolk"
  ["Sakhalin Standard Time"]="Asia/Sakhalin"
  ["Central Pacific Standard Time"]="Pacific/Guadalcanal"
  ["Russia Time Zone 11"]="Asia/Kamchatka"
  ["New Zealand Standard Time"]="Pacific/Auckland"
  ["UTC+12"]="Etc/GMT-12"
  ["Fiji Standard Time"]="Pacific/Fiji"
  ["Chatham Islands Standard Time"]="Pacific/Chatham"
  ["UTC+13"]="Etc/GMT-13"
  ["Tonga Standard Time"]="Pacific/Tongatapu"
  ["Samoa Standard Time"]="Pacific/Apia"
  ["Line Islands Standard Time"]="Pacific/Kiritimati"
)

cp /tmp/calendar.ics /tmp/calendar_corrected.ics

for W_TIMEZONE in "${!TIMEZONES[@]}"
do  TIMEZONE="${TIMEZONES["$W_TIMEZONE"]}"
    sed -i "s|TZID=$W_TIMEZONE|TZID=$TIMEZONE|" /tmp/calendar_corrected.ics
done

PS. If you're seeing this bug because you had this problem while trying to import from outlook, then you will probably also be interested in fixing the other outlook-importing problem, which has to do with zero-duration events. See https://github.com/lfos/calcurse/issues/400