Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Made the talks model use the timezone helper for consistency

  • Loading branch information...
commit 8ea548fdc0d069a052268e246cac2f2ced3aafcc 1 parent 3d254c2
@magicmonkey magicmonkey authored
Showing with 5 additions and 19 deletions.
  1. +5 −19 src/system/application/models/talks_model.php
View
24 src/system/application/models/talks_model.php
@@ -504,34 +504,20 @@ public function search($term, $start, $end) {
* @return the amended array with additional fields
*/
public function setDisplayFields($det) {
+ $this->load->library('timezone');
+
$retval = array();
foreach ($det as $talk) {
- // create datetime object
- $talk_datetime = new DateTime("@{$talk->date_given}");
// if a timezone is specified, adjust times
if (!empty($talk->event_tz_cont) && !empty($talk->event_tz_place)) {
- $event_timezone = new DateTimeZone($talk->event_tz_cont . '/' . $talk->event_tz_place);
+ $a = $talk->event_tz_cont . '/' . $talk->event_tz_place;
} else {
- $event_timezone = new DateTimeZone('UTC');
+ $a = 'UTC';
}
- $talk_datetime->setTimezone($event_timezone);
-
-
- // How much wrong will ->format("U") be if I do it now, due to DST changes?
- // Only needed until PHP Bug #51051 delivers a better method
- $unix_offset1 = $event_timezone->getOffset($talk_datetime);
- $unix_offset2 = $event_timezone->getOffset(new DateTime());
- $unix_correction = $unix_offset1 - $unix_offset2;
-
-
- // create datetime object corrected for DST offset
- $timestamp = $talk->date_given + $unix_correction;
- $talk_datetime = new DateTime("@{$timestamp}");
- $talk_datetime->setTimezone($event_timezone);
-
+ $talk_datetime = $this->timezone->getDatetimeFromUnixtime($talk->date_given, $a);
// set a datetime string, ignoring talks at midnight and assuming they are without times
if ($talk_datetime->format('H') != '0') {
Please sign in to comment.
Something went wrong with that request. Please try again.