Home › Forums › Calendar Products › Event Aggregator › Maybe usefull code for timezones fix
- This topic has 16 replies, 7 voices, and was last updated 8 years, 9 months ago by Support Droid.
-
AuthorPosts
-
October 4, 2012 at 5:59 am #26073ThomasParticipant
Okay i’ve written for my clients own simple fb_stream_events and all times are set correct. I post the here and hope this will help to find the problem inside facebook_importer
‘196555860474817’,
‘secret’ => ‘925d3a7df5534746b92541aff1daa8d4’,
‘cookie’ => true, // enable optional cookie support
));// Attempt to fetch kultmarks’s events page
// place access token for your fanpage after events?access_token=
// also place your fanpage that you would like to pull events from in $events=$facebook->api(‘/fanpage_here/
try{
$fql = “SELECT eid, name, location, description, pic_big, start_time FROM event
WHERE creator = ‘$fbNameToId’ AND eid IN
(SELECT eid FROM event_member WHERE uid = ‘$fbNameToId’)
ORDER BY start_time asc LIMIT 5″;
$param = array(
‘method’ => ‘fql.query’,
‘query’ => $fql,
‘callback’ => ”
);
$events=$facebook->api($param);
}catch (FacebookApiException $e){
error_log($e);
}// Iterate through each event
foreach ($events as $event){
// Get the start time of the event and convert it to a UNIX timestamp (hopefully)// If the time falls within a day, show the event details. If the event is after today, show it as well.
// 60 (seconds/minute) * (60 minutes/hour) * 24 (hours/day) * 1 (day)try{
// Fetch more details about the event
$start_time = date(‘M j, Y H:i ‘, strtotime($event[‘start_time’]));
}catch (FacebookApiException $e){
// We errored 🙁
error_log($e);
}// Show some HTMLsauce
?>October 4, 2012 at 6:01 am #26074ThomasParticipantand here’s example of working script with correct times: http://www.radionation-band.de right in the sidebar upcoming events
October 4, 2012 at 1:28 pm #26103BarryMemberHi Thomas – you’re referring to the issue with Facebook events being imported using Pacific Standard Time right?
October 4, 2012 at 1:31 pm #26105BarryMember… It would be great to pass this up to our devs – could I ask you to provide the code one more time, but using a service like Pastebin or Gist (our forum currently doesn’t handle code nicely and it’s likely that some parts of the code you posted will have changed/disappeared).
Thanks!
October 5, 2012 at 3:52 am #26132ThomasParticipantNo problem here’s the code on gist:
https://gist.github.com/3839229
hopefully this will help 🙂October 5, 2012 at 7:04 am #26139BarryMemberThanks Thomas – I’ll pass that on, thank you for sharing 🙂
November 8, 2012 at 8:33 pm #27761KristinParticipantHi Barry,
Is there any way yet for someone like me, who doesn’t code, to implement a fix for the time zone issue? Any documentation to explain how to implement a fix? Any update coming soon?I just installed the plugin today and I’m going to have to remove it today and ask for a refund if this time zone thing doesn’t get fixed immediately. This was the perfect plugin for me and now because of this time zone problem, it’s useless. :/
Thanks for your time & efforts,
KristinNovember 9, 2012 at 7:23 am #27773BarryMemberHi Kristin, sorry to hear that this has been causing problems for you. Currently there is no fix (beyond what Thomas posted, above) but if you could bear with me I am just checking in with the team to confirm how close (or far away) a substantive fix might be.
November 9, 2012 at 10:27 am #27791BarryMemberThanks for your patience.
I’m afraid a substantive fix is a release or two away at best. The problem is multi-faceted and my understanding is that it ultimately stems from the fact that Facebook returns times as if they were Pacific Standard Time: it would be interesting to know if you or another user has approached Facebook and asked about altering this so returned ates/times reflect your own timezone.
Of course, assuming it is always going to be a time returned in PST, our plugin has no way to know if that is deliberate (for a number of users this will be correct by default) or even if you definitely want all times to be corrected using the same adjustment (perhaps you are based in the east but publish events in a variety of different timezones).
So we’re definitely aware of the problem but a final solution that will fit the needs of all our users will not be appearing today or even next week; in all likelihood it is going to be a matter of some months.
This is definitely less-than-ideal but it can be managed manually. Also, for straightforward scenarios where a fixed adjustment (of -3hrs, for example) is required, it may be possible to implement this by clever use of filters and actions – so that’s another avenue you might consider exploring.
November 9, 2012 at 10:28 am #27792BarryMember* should have read, so that returned dates/times…
February 3, 2013 at 7:26 pm #32038Timothy WoodParticipantHello all, just wanted to let you know we have made progress to the timezone issue and will be releasing a patch soon for this issue. If you want to patch your importer in the meantime use this function (https://gist.github.com/4704496) to update the create_local_event method in the the-events-calendar-facebook-importer.php file. Add this method to your functions.php file in your theme and then this block of code within `if( isset( $facebook_event->id ) ) {` statement:
`// fix facebook date offsets -8
$timezone = ‘America/Los_Angeles’;
wp_convert_to_timezone( $facebook_event->start_time, $timezone );
wp_convert_to_timezone( $facebook_event->end_time, $timezone );
`
Once the update to the Facebook Events comes out – you will want to cleanup your functions file and remove this code since it will be unused with our new code.February 3, 2013 at 8:31 pm #32039Timothy WoodParticipantA bit of an update if you just dump this bit of code into your functions.php file. https://gist.github.com/4705028 until our update comes out this will fix any imported events.
February 5, 2013 at 8:06 am #32147AntonioParticipanthey guys and sorry for the following comment, but for me it does not make any sense to sell a plugin that does not do the job. because if at the end I need to manually change the event details, hour,etc…then, what is the utility of the plugin for? It does not make sense, then I will look at FB for the events and then create event by event in Worpdress.
Anything that is not autmomatic in terms of importing data from FB, I do not see the benefit…Imagine that I want to import events from 100 fan pages with 3 events per page, I still have to review and change the 300 events created in WP.
Sorry for this comment, but it is my opinion and somehow I feel extremely disappointed for purchaing a plugin that does not achieve what it is intended to be delivering.
best regards,
AntonioFebruary 5, 2013 at 8:29 am #32150RobMemberHey Antonio, thanks for the note and for your feedback on this. We greatly appreciate when people take the time to relay their thoughts on the product and how it is or isn’t working for you, and I can understand your frustration on this end.
I would take issue with your comment that the plugin “does not achieve what it is intended to be delivering,” though. As you may be aware, the timezone issue – where events import to WP in Pacific Standard Time – is entirely a Facebook issue and unfortunately something we as plugin developers have no control over. FB sets it how they want it, and we take what we can get via their API. By providing the solution above, we’ve just tried to go the extra mile to fix a bug in Facebook’s API (which according to Facebook’s TRAC system, they’ve been aware of for a while). While we definitely can understand your position, we hope you’ll understand ours too: mainly that there are limits to what we can do when it comes to “fixing” problems with a third-party service.
Based on your note above, it sounds like you haven’t imported anything yet – and if you apply this patch and then import, it should work 100%. The tweak will not impact any events you’ve already imported (ie cannot work retroactively), as that would have a big chance of screwing up date info. If you want to cycle through previously imported events and update the dates you could do so, but do it at your own risk (as it could update events that have the correct date/time already displayed).
Let me know your thoughts in light of the above. While we generally do not give refunds due to a problem with a third-party service, I want to do right by you…so if you feel one is fair please email me (rob /a/ tri.be) and we can take care of it. Thanks again for your understanding and patience so far.
February 5, 2013 at 9:06 am #32151AntonioParticipantHello Rob,
Thank you very much for you email and reply. Please let me check if with the fix the problem is sorted out.So far I have the problem that I do not know where the patch code should be placed as i do not have a functions.php but a template-functions.php
I have attached the template-function.php (in an private email) file but I do not know where to insert the code proposed by Tim Wood in the Forum, as stated below:setTimezone(new DateTimeZone(‘GMT’));
// modify the timezone with offset
$datetime_obj->modify( $gmt_offset . ‘ hours’ );// return datetime
$datetime = $datetime_obj->format( $return_format );
}// example to convert start_time of Facebook event
offset_date_to_timezone( $facebook_event->start_time, ‘America/Los_Angeles’ );Thank you very much for your help, support and reply,
Best regards,
Antonio Alcocer -
AuthorPosts
- The topic ‘Maybe usefull code for timezones fix’ is closed to new replies.