Event Calendar Widget : Timezone issues

Greetings

Our elgg site is used exclusively by people in the same timezone. We find that the "Calendar Events" widget icon for each event shows the wrong date if the event is within the next day, because our timezone is 12 hours from UTC. This is causing real confusion in our team as to what day the event is happening. I would love to be able to hide the icon on the widget and just show the date and time; or to handle events just with the same consistent timezone that we are all in.

Can anyone advise on this one, please? Really struggling...

Also, we're keen to use the events list widget - but for some reason it is displaying the events in the order that they are created, rather than the order that they are due to happen - and I simply can't seem to find out why this is happening; having researched it.

Please; any help with this would be very very gratefully received...

With sincere thanks

Jamie

  • I can't give you any answers (yet). I can only say that I'll try to look into the issues and try to fix them and make a new release then if necessary.

    Some questions though:

    • what do you mean with "widget icon"? I don't know what exactly you are referring to with this term and therefore I have trouble to find the element that is supposed to show the wrong date. Within widgets the date of an event entry is shown as part of the event list item and not part of the (user) icon. Are you referring to the event widgets you can add to profile pages, dashboards, index page and group pages?
    • regarding the order of the events: is the order wrong for you only in the widget on the index page? This seems wrong indeed (and inconsistent to the other widgets). Reason is that the fetching of events is done differently for the index page widget (and I have to admit that I didn't notice the order of events is not by date).

    With the wrong date displayed I need to do further testing (specifically with different timezones set). But it would help to have some pointers for you regarding the locations on the site you get wrong dates showing up.

  • Greetings

    Oh thank you SO much for coming back to me!! I am so, so grateful!

    Sorry for my lack of clarity; this is the only element which shows up wrongly is the little blue icon of a calendar page that has the month at the top and the date at the bottom. It shows the wrong number, but only if the event is within 24 hours. If you hover over it, it shows the right date. Everything else rocks!

    The event ordering - yes! Again, the only issue is with the widget on the index page.

    Once again - wholehearted thanks for giving this your attention,

    Jamie

  • Sorry, but I still have trouble finding the widget icon you are referring to. Maybe I'm blind and I just miss it. Is it displayed on your site in the event calendar widget(s) or somewhere else? Which version of Event Calendar and Elgg are you using?

    Another possibility (and I think a likely possibility) is that this widget icon is displayed on your site (instead of the user icon of the event creator that's supposed to show up where I suspect this widget icon is displayed) because another plugin (e.g. your theme) modifies (overrides) the widget code of the Event Calendar plugin for this icon to appear. You could test by disabling your theme temporarily to see if this makes a difference. If the user avatar would be displayed then instead of this date icon, I would need to know which plugin does modify the output. Or at least I would need to know the code of mod/OTHER_PLUGIN/views/default/widgets/index_event_calendar/content.php and maybe also mod/OTHER_PLUGIN/views/default/object/event_calendar.php. If any other plugin has these files, they would override the output created by Event Calendar with their own version.

    I had no time yet to look into the sorting issue (or rather no time to fix it).

  • Greetings - thanks for coming back to me. How intriguing!

    We don't have a 'theme' as such - I mean we have a bunch of plugins, but none of them, so far as I can see, are likely to impact on that. Nothing's overriding the standard stuff, by the looks of things :

    # find . -name index_event_calendar
    ./mod/event_calendar/views/default/widgets/index_event_calendar

    and :

    # find . -name event_calendar.php
    ./mod/event_calendar/views/default/object/event_calendar.php
    ./mod/event_calendar/views/default/admin/administer_utilities/event_calendar.php
    ./mod/event_calendar/views/rss/object/event_calendar.php

    ...so it looks as if Event Calendar is doing its own thing. I'm running version 2.3.3 of elgg, and version 2.3.1 of Event Calendar.

    Here's a screenshot of what appears in the widget. Again, I can't thank you enough for your help and your time...

    Jamie

  • It seems this widget is not from the Event Calendar plugin but from the Event Manager plugin. See the second example image at https://elgg.org/plugins/736695. Do you have both of these plugins enabled or the Event Calendar even enabled currently?

  • Yes! You're absolutely right, of course it is! Doh....

    We use both plugins. We use Event Manager for private appointments that relate to Groups, so that only members of those groups see the events in the widget; and Events Calendar for a system-wide calendar that everyone can see. Do I have the distinction between the plugins correct (excuse my confusion!) - or is it possible to connect events in the Events Calendar to Groups?

    So, the problem with the widget display is indeed with Event Manager.

    The problem we're having with the sorting is with Event Calendar!

    Once again, apologies for the confusion in my post...!
    Jamie

  • The Event Calendar plugin also offers group calendars. Check the plugin settings to see if group calendars are enabled (in general) and if they are enabled or disabled per group (in which case you would enable the group calendar in the group's settings explicitely). With group calendars enabled you can add group events directly if you are within a group context or select the group's calendar as the target calendar (as opposed to the default site-wide calendar) when outside a group context. The access level of an event entry (who can see the event) is a separate option when adding an event (further down on the form). One thing that currently doesn't work is moving events from one calendar to another (e.g. from site-wide calendar to a group calendar or vice versa) even if this option is displayed when editing an event (I had no time yet to fix that). Also, don't get confused if an event always shows up on your personal calendar if you have added this event on your own. There's also a plugin setting for that (default is to add an event to the personal calendar when adding it).

    With regards to the Event Manager widget icon issue you can try a change in mod/event_manager/views/default/icon/object/event.php. Change the use of the date() function to gmdate() in the following two lines:

    $icon .= "<div class='event_manager_event_list_icon_month'>" . strtoupper(gmdate("M", $start_day)) . "</div>";
    $icon .= "<div class='event_manager_event_list_icon_day'>" . gmdate("d", $start_day) . "</div>";

    And for the sorting issue with the index page widget of Event Calendar replace the code of mod/event_calendar/views/default/widgets/index_event_calendar/content.php with

    <?php
    
    //the number of events to display
    $num = (int) $vars['entity']->events_count;
    if (!$num) {
        $num = 4;
    }
    
    // Display $num (personal and group) events
    // but don't show events that have been over for more than a day
    // TODO How to deal with recurring events?
    $one_day = time() - 60*60*24;
    $options = array(
        'type' => 'object',
        'subtype' => 'event_calendar',
        'metadata_name_value_pairs' => array(
                array('name' => 'start_date', 'value' => $one_day,  'operand' => '>'),
                array('name' => 'end_date', 'value' => $one_day,  'operand' => '>'),
            ),
        'metadata_name_value_pairs_operator' => 'OR',
        'order_by_metadata' => array(
                'name' => 'start_date',
                'direction' => ASC,
                'as' => 'integer'
            ),
        'limit' => $num,
    );
    
    $events = elgg_get_entities_from_metadata($options);
    
    // If there are any events to view, view them
    if (is_array($events) && sizeof($events) > 0) {
        echo "<div id=\"widget_calendar\">";
        foreach($events as $event) {
            echo elgg_view("object/event_calendar", array('entity' => $event));
        }
        echo "</div>";
    } else {
        echo elgg_echo('event_calendar:no_events_found');
    }

    I'll make a new release of the Event Calendar plugin possibly soon which will include this fix. But I would like to see what other changes I can include in the next release (e.g. the index page widget fix can also improve the code for the other widgets with some adjustments).

  • Greetings

    This is fantastic; can't believe I missed that. So excited to see precisely the functionality that we need! It really is the most comprehensive plugin.... congratulations...

    Couple of questions, if I may :

    ...I'd like to display the current month's calendar in a widget for all users to see. I guess I could achieve this by simply replicating the code in full_calendar_view.php - but how can I specify start date as today, to that it always shows this month's calendar? I know this is probably incredibly obvious, but I've not been able to get it to work so far.

    Secondly; I'd really, really like to return a list of events of a particular type for a text list-style display in another widget. For example, I'd like to show start date and description of any current or future events with the type "foo". I assume this would be relatively easy?

    Very grateful thanks for your help....

    Jamie

  • I guess it might work if you use the code of full_calendar_view.php as the code of content.php of the widget with

    $timeformat = elgg_get_plugin_setting('timeformat', 'event_calendar') == 24 ? 'H(:mm)' : 'h(:mm)t';
    $startdate = date('n', now()) - 1;

    and the other variables not used. But I doubt it will be of much use to have the full calendar displayed in a widget. If the layout is displayed correctly even, the calendar is most likely quite tiny. I would think it better to display the events in a list in a widget.

    Listing events of a certain event type in a widget should work with

    $options = array(
        'type' => 'object',
        'subtype' => 'event_calendar',
        'metadata_name_value_pairs' => array(
                array('name' => 'start_date', 'value' => $one_day,  'operand' => '>'),
                array('name' => 'event_type', 'value' => 'foo',  'operand' => '='),
            ),
        'order_by_metadata' => array(
                'name' => 'start_date',
                'direction' => ASC,
                'as' => 'integer'
            ),
        'limit' => $num,
    );

    with rest of code according to mod/event_calendar/views/default/widgets/index_event_calendar/content.php.

  • Greetings

    I am just in awe.... thank you - of course that worked absolutely perfectly. Displaying the calendar in a widget works fine for us - we're using a full-width row - it's important that it's the first thing our team see when they hit the page; so they don't miss stuff.

    Two more questions, if I may :

    - Despite having edited mod/event_calendar/models/model.php to ensure that the first day of the week comes in as 1, the calendar persistently starts with a Sunday. Any idea why this might be happening?

    - With the widget showing a list of events; how can I avoid the list showing the creator's avatar, please?

    Grateful thanks again for your time and expertise,

    Jamie