Context:
I'm trying to import events from a google calendar to an 'events' node type. My site is set to Detroit timezone.
What is happening:
When importing calendar entries from a google calendars .ics file, the datetime fields are in the following format [YYYY][MM][DD]T[HH][MM][SS]Z. I'm not 100% sure, but I think the 'Z' is the timezone code for Zulu, which is equivalent to +0000 UTC.
Anyhow, when those entries are imported, regardless of the timezone I've selected in the feeds mappings, they are entered as though they are an accurate local time, and are accordingly time-shifted +4 hours. This leads the datetime 20190619T110000Z to be entered as 2019-06-19T15:00:00 in the database, and then for that time to be shifted back -4 hours when displayed in a view.
What I would expect to happen:
In the mappings, the timezone select list says, "This value will only be used if the timezone is missing." I would guess that "Z" is not properly recognized as Zulu time (+0 UTC), but is also not recognized as "no timezone" leading it to this shadowy middle ground where the parser just treats it as a normal time.
Perhaps something else that could be useful is an option to force a specific timezone, regardless of if one is already provided.
| Comment | File | Size | Author |
|---|---|---|---|
| #10 | 3062885-10-feeds_ical-timezone-fix.patch | 1.52 KB | mekal |
| #9 | 3062885-9-feeds_ical-timezone-fix.patch | 1.85 KB | mekal |
| #8 | 3062885-8-feeds_ical-timezone-fix.patch | 1.85 KB | vselivanov |
| #6 | feeds_ical-timezone-fix-3062885-6.patch | 3.84 KB | catapipper |
| #4 | feeds_ical-timezone-fix-3062885-4.patch | 1.36 KB | damondt |
Issue fork feeds_ical-3062885
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
drshearer commentedHey, I had the exact same issue today. I was able to get my Google .ics to import correctly by removing lines 69-74 in /src/Feeds/Parser/IcalParser.php, i.e.:
Just delete those lines and leave everything else as is, and the time zone handling should work fine. Hope this helps!
Comment #3
andy-blumI cannot emphasize how clutch your timing is, tamarackmedia. Thanks for the assist.
Comment #4
damondt commented@tamarckmedia @ablum I added this as a patch. Any testing you wanted to do on it would be appreciated, especially on use cases besides the one that lead to finding this issue.
Comment #5
damondt commentedComment #6
catapipperWhile this does fix the timezone issue it breaks All Day events, making the date set to August 22, 1970 with all kinds of different times.
I updated the patch to take this into account and while it's probably not the most elegant solution it works. I took advantage of All Day events not having a time set so that these events get the Unix timestamp while the other events get the ISO standard pulled over. This basically sets the All Day events to midnight and the other events to whatever time they need to be based on the ISO standard.
Comment #7
scottsawyerThis patch worked for me. Huge thank you.
Comment #8
vselivanov@catapipper Thank you, patch #6 works for me with Feeds iCal 8.x-1.2.
With or without patch #6 I have a php notice (see below). It works fine with periodical background import (just a notice in dblog), but break manual import with batch.
I believe empty dtend_array event property comes from the feed source - when end date is empty.
Patch is attached. It's not related to the patch #6 or issue in this thread. But it changes the same code as the critical patch #6. So I've just updated it to avoid conflicts.
Comment #9
mekal commentedPatch #8 didn't apply for me on 2.04 because of a single space. Attaching a fix!
Comment #10
mekal commentedSorry, messed #9 up...this one should work.
Comment #11
ben.hamelinComment #13
ben.hamelinThis new MR addresses the timezone issue more directly. Checking for "T" isn't reliable given the various forms of date strings we might see, including something like "DTSTART;TZID=America/New_York:19980312T083000"
The ICal\ICal class provides the timezone in the date arrays like
Array ( [0] => Array ( [TZID] => Europe/Berlin ) [1] => 20240410T140000 [2] => 1712750400 [3] => TZID=Europe/Berlin:20240410T140000 )In this way, we can identify if a timezone was provided and use it appropriately, which in the case above involves formatting the date string like:
20240410T140000Europe/BerlinSee related Feeds issue: https://www.drupal.org/project/feeds/issues/3070757
With this MR, formatting using the provided timezone results in the Feeds DateTargetBase class creating the date using the provided timezone. See: https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Datetime%...
"Note that the $timezone parameter and the current
* timezone are ignored when the $time parameter either is a UNIX timestamp
* (e.g. @946684800) or specifies a timezone
* (e.g. 2010-01-28T15:00:00+02:00)."
In my testing imported events without timezone were unaffected, while events with them were adjusted accordingly to match my site's default setting.
If I could get some testing here that would be awesome! Thanks!
Comment #15
ben.hamelinComment #16
peter pulsifer commentedIn my Feeds mapping I have selected
DTSTART (unix timestamp)and when there is a timezone in the feed I am now getting a string such as 20250405T120000America/New_York, which is causing fatal PHP errors when I pass it to date(). This is almost certainly a change in behavior. There is a mapping forDTSTART RAW (string format from source)but I have never used it.Feeds that don't use a TZID specification continue to return the timestamp to my processor as always.
Of course, correct processing of timezone is important, but I hope we can keep the behavior of returning a unix timestamp when specified.
Comment #17
ben.hamelinThanks @peter pulsifer I will take a look at this tomorrow. That mapping should indeed pass the timestamp directly.
Are you able to share an example .ics / .ical that you're working with?
Comment #18
peter pulsifer commentedThanks @ben.hamelin. One example feed is https://griffinmuseum.org/events/?ical=1.
This one has no TZID and the importer gives the timestamp: http://api.membershipworks.com/v2/events?_op=ics&org=14015
Comment #19
ben.hamelin@peter pulsifer Sorry I am battling with Gitlab.... going to open a new issue so this is quicker. I can't seem to rebase the issue fork from the source project from the Gitlab UI.
Comment #20
ben.hamelinhttps://www.drupal.org/project/feeds_ical/issues/3517541