aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorThomas Müller <thomas.mueller@tmit.eu>2015-04-07 11:13:05 +0200
committerThomas Müller <thomas.mueller@tmit.eu>2015-04-07 11:13:05 +0200
commit1f8e6e78ccfb053388f9f4790ccbe74ef557889c (patch)
tree2671f7139f4796a21296dfef9874c22033220580 /lib
parent95e55aa4adb690947ff73f2c703dac7010ed2cae (diff)
parent0fcd273714a4dd75e2fa8a59fea0fe38cd5aa934 (diff)
downloadnextcloud-server-1f8e6e78ccfb053388f9f4790ccbe74ef557889c.tar.gz
nextcloud-server-1f8e6e78ccfb053388f9f4790ccbe74ef557889c.zip
Merge pull request #15424 from owncloud/failing-master-tests
Fix failing tests related to timezones on master
Diffstat (limited to 'lib')
-rw-r--r--lib/private/datetimezone.php16
-rw-r--r--lib/public/idatetimezone.php3
2 files changed, 14 insertions, 5 deletions
diff --git a/lib/private/datetimezone.php b/lib/private/datetimezone.php
index acc956e66f3..512c39be3ea 100644
--- a/lib/private/datetimezone.php
+++ b/lib/private/datetimezone.php
@@ -48,13 +48,14 @@ class DateTimeZone implements IDateTimeZone {
/**
* Get the timezone of the current user, based on his session information and config data
*
+ * @param bool|int $timestamp
* @return \DateTimeZone
*/
- public function getTimeZone() {
+ public function getTimeZone($timestamp = false) {
$timeZone = $this->config->getUserValue($this->session->get('user_id'), 'core', 'timezone', null);
if ($timeZone === null) {
if ($this->session->exists('timezone')) {
- return $this->guessTimeZoneFromOffset($this->session->get('timezone'));
+ return $this->guessTimeZoneFromOffset($this->session->get('timezone'), $timestamp);
}
$timeZone = $this->getDefaultTimeZone();
}
@@ -74,9 +75,10 @@ class DateTimeZone implements IDateTimeZone {
* we try to find it manually, before falling back to UTC.
*
* @param mixed $offset
+ * @param bool|int $timestamp
* @return \DateTimeZone
*/
- protected function guessTimeZoneFromOffset($offset) {
+ protected function guessTimeZoneFromOffset($offset, $timestamp) {
try {
// Note: the timeZone name is the inverse to the offset,
// so a positive offset means negative timeZone
@@ -93,7 +95,13 @@ class DateTimeZone implements IDateTimeZone {
// we try to guess one timezone that has the same offset
foreach (\DateTimeZone::listIdentifiers() as $timeZone) {
$dtz = new \DateTimeZone($timeZone);
- $dtOffset = $dtz->getOffset(new \DateTime());
+ $dateTime = new \DateTime();
+
+ if ($timestamp !== false) {
+ $dateTime->setTimestamp($timestamp);
+ }
+
+ $dtOffset = $dtz->getOffset($dateTime);
if ($dtOffset == 3600 * $offset) {
return $dtz;
}
diff --git a/lib/public/idatetimezone.php b/lib/public/idatetimezone.php
index 30fbde15ac8..eb74074aa46 100644
--- a/lib/public/idatetimezone.php
+++ b/lib/public/idatetimezone.php
@@ -25,7 +25,8 @@ namespace OCP;
interface IDateTimeZone {
/**
+ * @param bool|int $timestamp
* @return \DateTimeZone
*/
- public function getTimeZone();
+ public function getTimeZone($timestamp = false);
}