Skip to content
Browse files

proper fix to account for timezone or offset

  • Loading branch information...
1 parent 0dbd327 commit 8b588d959fc5db6729e1c214fe3945d251292ece @alexkingorg alexkingorg committed Oct 24, 2012
Showing with 15 additions and 10 deletions.
  1. +14 −9 classes/aktt.php
  2. +1 −1 classes/aktt_tweet.php
View
23 classes/aktt.php
@@ -1116,15 +1116,20 @@ static function download_tweet($status_id, $username = null) {
}
static function gmt_to_wp_time($gmt_time) {
- $gmt_date = date('Y-m-d H:i:s', $gmt_time);
-
- // Not using get_option('gmt_offset') because it gets the offset for the
- // current date/time which doesn't work for timezones with daylight savings time.
- $datetime = new DateTime($gmt_date);
- $datetime->setTimezone(new DateTimeZone(get_option('timezone_string')));
- $offset_in_secs = $datetime->getOffset();
-
- return $gmt_time + $offset_in_secs;
+ $timezone_string = get_option('timezone_string');
+ if (!empty($timezone_string)) {
+ // Not using get_option('gmt_offset') because it gets the offset for the
+ // current date/time which doesn't work for timezones with daylight savings time.
+ $gmt_date = date('Y-m-d H:i:s', $gmt_time);
+ $datetime = new DateTime($gmt_date);
+ $datetime->setTimezone(new DateTimeZone(get_option('timezone_string')));
+ $offset_in_secs = $datetime->getOffset();
+
+ return $gmt_time + $offset_in_secs;
+ }
+ else {
+ return $gmt_time + (get_option('gmt_offset') * 3600);
+ }
}
}
View
2 classes/aktt_tweet.php
@@ -543,7 +543,7 @@ function create_blog_post($args = array()) {
$post_content .= "\n\n".wp_get_attachment_image($this->featured_image_id, $size);
}
- $gmt_time = self::twdate_to_time($this->meta['created_at']);
+ $gmt_time = self::twdate_to_time($this->date());
// Build the post data
$data = array(

0 comments on commit 8b588d9

Please sign in to comment.
Something went wrong with that request. Please try again.