I am trying to get event_views to correctly query the database for events that use an event-specific timezones and there is no way to do it cleanly. What I propose is that we add two columns to the event table to store the start and end offset values for events that have their own timezones. There would be nothing stored in the database for events that use user or site timezones since in those cases the offsets can be determined easily, plus they need to be calculated at the time of the query based on user and site preferences.

With this patch the event views module has a database value it can incorporate into its query for events that have their own timezones. The patch also makes the event module a bit more efficient when event timezones are used by retreiving the offsets from the database during node_load() instead of including the timezone file and executing event_get_offset() on each node when it is loaded.

The changes are minimal and shouldn't break anything else. The only issue is that it does require a database update.

By way of background, when I realized event-specific timezones are going to create problems in Views queries, I tried to figure out why this isn't a problem for the event module, too. When I dug through the event module code I found that the way the event module handles this is by doing a very broad query (querying the whole month even if you are only viewing a single day on the calendar), then individually loading each node retrieved in the query, which pushes dates with event-specific timezones through the event_get_offset() function to identify the offset and format the date, then excluding nodes from the calendar if the resulting dates and date offsets don't match the required parameters. That method gets the right nodes on the calendar, but is way too complicated for Views queries (and probably more complicated than it needs to be or the event module).

CommentFileSizeAuthor
event_head.patch6.12 KBkarens

Comments

gerhard killesreiter’s picture

Two points:

the update needs to be run in all cases, who knows if the user wants to change the way event TZs are displayed.

I don't like the if-thens. Can't we set the offset vars to 0 and only have one sql query?

liquidcms’s picture

is it safe to say this patch still doesn't help integrate offset info into views ??

- i have a view block which pulls in start and timezone values for an event enabled node
- i get the start and timezone values but not sure without offset they can help me display real event date (i.e. as it was entered originally with a timezone).
- i have run the patch and can see that it added a offset field and even updated the values for most of my records (not sure why some are still null??)

- but this info isn't pulled into views anywhere and therefore isnt available when i make a template for my block.. which i think means i still need to do a node_load (which i guess isnt that efficient since on my home page i list 30-40 teasers)

i did notice that with october-ish version of event module i didn't have access when tpl was being processed to the event.inc functions (where concievably i could calc offset from zid and start) but with latest version i now seem to be able to access this function.. which is good.. but then not sure i get the value of this patch??

liquidcms’s picture

ok, my bad.. i guess i still don't have access to functions in event.inc and therefore major pain to put a real date/time/tz value into my block.

i guess i can do an include of the event.inc.. but seems pretty messy for simple block

liquidcms’s picture

sorry the file with the function si need is actually event_timezones.inc

and, in case i am not just completely confused about all this.. this is the code i need to add to my template to get the correct date/time displayed:

// date of resource
$path=drupal_get_path('module','event');     // pretty stupid that i need to do this ???
include_once("$path/event_timezones.inc");
$zones = event_zonelist();
$start_offset = event_get_offset($node->event_timezone,$node->event_event_start);
$date = _event_date("F j, Y",$node->event_event_start, $start_offset);
$time = _event_date("g:i a",$node->event_event_start, $start_offset);  
$tz = $zones[$node->event_timezone];

pretty sure this should be easier than this.

killes@www.drop.org’s picture

Status: Needs review » Needs work

as commented

killes@www.drop.org’s picture

Status: Needs work » Closed (won't fix)

spoke to KarenS: She doesn't need it anymore.