Skip to content
This repository has been archived by the owner on Aug 2, 2019. It is now read-only.

Commit

Permalink
Merge remote-tracking branch 'fridgesm/bug274'
Browse files Browse the repository at this point in the history
  • Loading branch information
lornajane committed Mar 19, 2013
2 parents 71ead58 + 55ae6ef commit 4256d22
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 24 deletions.
19 changes: 2 additions & 17 deletions src/api-v2/inc/Timezone.php
Expand Up @@ -47,16 +47,7 @@ public static function getDatetimeFromUnixtime($unixtime, $timezone)
}
$datetime->setTimezone($tz);

// 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 = $tz->getOffset($datetime);
$unix_offset2 = $tz->getOffset(new DateTime());
$unix_correction = $unix_offset1 - $unix_offset2;

// create datetime object corrected for DST offset
$timestamp = $unixtime + $unix_correction;

$datetime = new DateTime("@{$timestamp}");
$datetime = new DateTime("@{$unixtime}");
$datetime->setTimezone($tz);
return $datetime;
}
Expand Down Expand Up @@ -127,13 +118,7 @@ public static function UnixtimeForTimeInTimezone(
$dateObj->setDate($year, $month, $day);
$dateObj->setTime($hour, $minute, $second);

// 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 = $tz->getOffset($dateObj);
$unix_offset2 = $tz->getOffset(new DateTime());
$unix_correction = $unix_offset1 - $unix_offset2;

$unixTimestamp = $dateObj->format("U") - $unix_correction;
$unixTimestamp = $dateObj->format("U");

return $unixTimestamp;
}
Expand Down
8 changes: 1 addition & 7 deletions src/system/application/controllers/talk.php
Expand Up @@ -274,13 +274,7 @@ function add($id = null, $opt = null)
$this->input->post('given_min'), $talk_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 = $talk_timezone->getOffset($talk_datetime);
$unix_offset2 = $talk_timezone->getOffset(new DateTime());
$unix_correction = $unix_offset1 - $unix_offset2;
$unix_timestamp = $talk_datetime->format("U") - $unix_correction;
$unix_timestamp = $talk_datetime->format("U");

$arr = array(
'talk_title' => $this->input->post('talk_title'),
Expand Down

0 comments on commit 4256d22

Please sign in to comment.