{"id":452,"date":"2008-07-04T04:17:44","date_gmt":"2008-07-04T11:17:44","guid":{"rendered":"http:\/\/www.alephnaught.com\/Blog\/?p=452"},"modified":"2008-07-04T04:25:29","modified_gmt":"2008-07-04T11:25:29","slug":"patch-for-twitter-tools-plugins-timezone-problem","status":"publish","type":"post","link":"https:\/\/www.alephnaught.com\/Blog\/2008\/07\/04\/patch-for-twitter-tools-plugins-timezone-problem\/","title":{"rendered":"Patch for Twitter Tools plugin&#8217;s timezone problem"},"content":{"rendered":"<div id=\"content_div-452\">\n<p>Since I got an extra day off from work yesterday, I had some time to spend on solving a problem.  I use Twitter Tools to display my five most recent tweets on my blog, as well as creating a digest post of my tweets every day, and a notification tweet of new posts to my blog.  Its a really nice plugin and a good piece of work.  But, it has a bug &#8211; Twitter returns tweets in UTC time, while some of the key comparisons inside Twitter Tools uses local time.  This affected the digest posts; some tweets would appear on the wrong day.<\/p>\n<p>It was hard to find all the comparison items and get them converted to UTC time, so I decided to convert the tweet time to local time using the setting in the WordPress application.  I&#8217;ve posted this patch to the WordPress support forum at <a href=\"http:\/\/wordpress.org\/support\/topic\/127916?replies=4#post-796201\" target=\"_blank\">http:\/\/wordpress.org\/support\/topic\/127916?replies=4#post-796201<\/a>.  Here&#8217;s the patch as well (this patch only applies to the 1.2b1 version):<\/p>\n<pre><span style=\"font-size: 7pt;\">*** twitter-tools.php.0\tSun Apr 13 20:07:12 2008\r\n--- twitter-tools.php\tThu Jul  3 13:06:44 2008\r\n***************\r\n*** 401,406 ****\r\n--- 401,409 ----\r\n\r\n  \tfunction add() {\r\n  \t\tglobal $wpdb, $aktt;\r\n+ \t\t\/\/ RLH: The next line corrects Twitter's UTC to WordPress timezone setting\r\n+ \t\t$this-&gt;tw_created_at = $this-&gt;tw_created_at + (get_option('gmt_offset') * 3600);\r\n+ \t\t\/\/ RLH: End changes\r\n   \t\t$wpdb-&gt;query(\"\r\n  \t\t\tINSERT\r\n  \t\t\tINTO $wpdb-&gt;aktt\r\n***************\r\n*** 1353,1358 ****\r\n--- 1356,1364 ----\r\n  {\r\n\r\n  \t$now = time();\r\n+ \t\/\/ RLH: Must shift \"now\" back to proper timezone to match WordPress\r\n+ \t$now = $now +  + (get_option('gmt_offset') * 3600);\r\n+ \t\/\/ RLH: End changes\r\n\r\n  \t$time = gmmktime(\r\n  \t\tsubstr($date, 11, 2)<\/span><\/pre>\n<p><span style=\"font-family: sans-serif;\">I hope that helps make this plugin more effective.  Perhaps the author could eventually fix all the comparisons and we could go back to using UTC for everything, as I think that&#8217;s the right answer.  But, this works for now.<\/span><\/p>\n<\/div>\n<div class=\"translate_block\" style=\"display: none;\">\n<hr class=\"translate_hr\" \/>\n<a class=\"translate_translate\" id=\"translate_button_post-452\" lang=\"en\" xml:lang=\"en\" href=\"javascript:show_translate_popup('en', 'post', 452);\"><span>Translate<\/span><\/a><img data-recalc-dims=\"1\" src=\"https:\/\/i0.wp.com\/www.alephnaught.com\/Blog\/wp-content\/plugins\/google-ajax-translation\/transparent.gif?resize=16%2C16&#038;ssl=1\" id=\"translate_loading_post-452\" class=\"translate_loading colorbox-452\" style=\"display: none;\" width=\"16\" height=\"16\" alt=\"\" \/>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Since I got an extra day off from work yesterday, I had some time to spend on solving a problem. I use Twitter Tools to display my five most recent tweets on my blog, as well as creating a digest post of my tweets every day, and a notification tweet of new posts to my [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[4],"tags":[207,142],"class_list":["post-452","post","type-post","status-publish","format-standard","hentry","category-computer","tag-twitter-tools","tag-wordpress"],"aioseo_notices":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p2w3Qj-7i","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.alephnaught.com\/Blog\/wp-json\/wp\/v2\/posts\/452","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.alephnaught.com\/Blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.alephnaught.com\/Blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.alephnaught.com\/Blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.alephnaught.com\/Blog\/wp-json\/wp\/v2\/comments?post=452"}],"version-history":[{"count":0,"href":"https:\/\/www.alephnaught.com\/Blog\/wp-json\/wp\/v2\/posts\/452\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.alephnaught.com\/Blog\/wp-json\/wp\/v2\/media?parent=452"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.alephnaught.com\/Blog\/wp-json\/wp\/v2\/categories?post=452"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.alephnaught.com\/Blog\/wp-json\/wp\/v2\/tags?post=452"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}