Changing times of imported events

WordPress Event Management, Calendars & Registration Forums iCal Extension Changing times of imported events

This topic contains 5 replies, has 2 voices, and was last updated by  Pedro Kaawaloa 9 years, 2 months ago.

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #18691

    Hello!

    So I’ve been reading up on the support forums here, and I have noticed that people have had issues with multiple timezones. I looked at this site in particular: http://wp-event-organiser.com/forums/topic/keeping-local-time-across-time-zones/

    I’d like some help with this. Unlike Beth, I believe that I have an iCloud .ics that does send timezone information. How do I use your script to adjust the time of an event based on the timezone recorded? I saw the code you shared in Beth’s post below, but I am not sure how to implement it. I’ve already put it in my own “site utility plugin”, as I saw you recommended in another post.

    1. How do I store the timezone as post meta information?
    2. How do I activate the adjustment by using the code?

    `
    add_filter( ‘eventorganiser_get_the_start’, ‘my_callback_function’, 10, 5 );
    function my_callback_function( $formatted_start, $start, $format, $post_id, $occurrence_id ){
    $timezone = get_post_meta( $post_id, ‘event_timezone’ );
    $timezoneobj = new DateTimeZone( $timezone );
    if( $timezoneobj ){
    $start->setTimezone( $timezoneobj );
    }
    //Change first value and return it
    return eo_format_datetime( $start, $format );</p></p>

    <p><</p>

    <p>p>};
    `

    Perhaps multiple timezone support would be a worthwhile addition to your script? I think it’s quite powerful, but this is a challenge as someone who had events across multiple timezones. If that is too difficult, is there perhaps a way to display event information based on the timezone of the person viewing the information?

    Thank you so much for all of your help with this issue!

    ~Pedro

    • This topic was modified 9 years, 2 months ago by  Pedro Kaawaloa.
    Pedro Kaawaloa
    #18713

    Okay, I have figured out how to get the timezone as a feed is inserted. How do I save that information along with the event? I’m assuming that all I have to do when loading the event is adjust the start time based on that timezone relative to the server’s timezone?

    Pedro Kaawaloa
    #18714

    Okay, I have figured out how to use the script I originally posted to adjust the timezone based on where the event is located. It works when I set the timezone directly in the code. However, I have no idea how to store the timezone from the original feed along with the event That is the only part that I am missing. Is anyone able to help me with that?

    ~Pedro

    Pedro Kaawaloa
    #18719

    What I basically need help with is understanding what function/hook I use to pull the timezone information from an event as it is parsed and save it as meta data for the post. Once I do that, I can use the script I posted above to update events on the fly. I am lost as to how to actually save the timezone in the meta…

    Do I use one of these?

    eventorganiser_ical_feed_parsed
    eventorganiser_ical_property_$property_lowercase

    I believe that I the code below use to save the information, correct?

    update_post_meta( $post_id, 'event_timezone', $value );

    I just don’t know which function/hook I use to send the $post_id and $tzid to the post_meta.

    I would really appreciate any help people are able to offer. I’d love to get this figured out in a timely manner. Thank you for your time!

    ~Pedro

    Pedro Kaawaloa
    #18729

    You can also use the eventorganiser_ical_sync_meta_key_map filter this allows you to map from the parsed event to a meta key that you would use with get_post_meta().

    The timezone of an event isn’t stored, but it is implicit in that the event’s start/end datetimes are DateTime objects. However note that all day events have the site timezone associated to them, regardless of what timezone they originally add. This is because all day events aren’t considered to be absolute dates.

    One thing you should be aware of is that the plug-in will convert all DateTime objects to the same timezone (site timezone) prior to inserting them into the database. This is intentional. What you would need to is use the stored timezone (i.e. using the snippet you posted earlier) when displaying the date.

    To store the timezone of the event you could do something like:

    add_action( 'eventorganiser_ical_property_dtstart', 'my_store_timezone', 10, 3 );
    function my_store_timezone( $value, $modifiers, $ical_parser ){
        $timezone = $ical_parser->current_event['start']->getTimezone();
         //Take a note of the key you use here, e.g. 'my_timezone'
         //you will need to map this to your desired post meta key
         //using eventorganiser_ical_sync_meta_key_map
        $ical_parser->current_event['my_timezone'] = $timezone->getName();
    }
    
    Stephen Harris
    #18836

    I forgot to say that I got this working. I want to thank you immensely for helping with it. I really needed help in finding the proper commands!

    Pedro Kaawaloa
Viewing 6 posts - 1 through 6 (of 6 total)
To enable me to focus on Pro customers, only users who have a valid license for the Pro add-on may post new topics or replies in this forum. If you have a valid license, please log-in or register an account using the e-mail address you purchased the license with. If you don't you can purchase one here. Or there's always the WordPress repository forum.