Home › Forums › Calendar Products › Events Calendar PRO › Timezone failing to get abbreviation for offset
- This topic has 2 replies, 3 voices, and was last updated 10 years ago by
Support Droid.
-
AuthorPosts
-
April 20, 2016 at 11:01 am #1104979
Brett
ParticipantI found that all events were displaying the UTC offset rather than the timezone abbreviation. I’m not sure if this is specific to us, or if it is common. After a bit of research, I found that there is a more reliable method to finding the abbreviation than simply passing it to the DateTimeZone class.
These are the changes made to more reliably get the abbreviation:
In Timezones.php, change the abbr function:
public static function abbr( $date, $timezone_string ) { try { if (strpos($timezone_string, 'UTC') === 0) { $offset = substr($timezone_string, 3); // Calculate seconds from offset list($hours, $minutes) = explode(':', $offset); $seconds = $hours * 60 * 60 + $minutes * 60; // Get timezone name from seconds $tz = timezone_name_from_abbr('', $seconds, 1); // Workaround for bug #44780 if ($tz === false) $tz = timezone_name_from_abbr('', $seconds, 0); $tz_date = date_create($date, new DateTimeZone($tz)); $formatted = $tz_date->format('T'); return $formatted; } $tz_date = date_create($date, new DateTimeZone($timezone_string)); $formatted = $tz_date->format('T'); return $formatted; } catch (Exception $e) { return ''; } }April 21, 2016 at 9:54 am #1105496Brian
MemberHi,
Thanks for using our plugins and for sharing your coding here.
This looks interesting and something we would want to look into.
Can you submit a Pull Request in the develop branch of Tribe Common Repo for it:
https://github.com/moderntribe/tribe-common
Also, if you could share your research on why this method is better that would be helpful for us too.
Let me know and thanks for sharing.
Cheers
May 6, 2016 at 9:35 am #1111520Support Droid
KeymasterThis topic has not been active for quite some time and will now be closed.
If you still need assistance please simply open a new topic (linking to this one if necessary)
and one of the team will be only too happy to help. -
AuthorPosts
- The topic ‘Timezone failing to get abbreviation for offset’ is closed to new replies.
