From c1f3f9c3d675ab40b3a1a7b73bcbbace2e42165c Mon Sep 17 00:00:00 2001
From: Thomas Steur <thomas.steur@googlemail.com>
Date: Mon, 3 Feb 2014 03:17:11 +0100
Subject: [PATCH] fix expected date for auckland / new zealand was wrong

---
 core/ScheduledTime.php                           | 7 +++++--
 tests/PHPUnit/Core/ScheduledTime/DailyTest.php   | 2 +-
 tests/PHPUnit/Core/ScheduledTime/MonthlyTest.php | 2 +-
 tests/PHPUnit/Core/ScheduledTime/WeeklyTest.php  | 2 +-
 4 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/core/ScheduledTime.php b/core/ScheduledTime.php
index 5060a33d56..53e1e86793 100644
--- a/core/ScheduledTime.php
+++ b/core/ScheduledTime.php
@@ -138,12 +138,15 @@ abstract class ScheduledTime
         $dateInTimezone     = Date::factory($arbitraryDateInUTC, $this->timezone);
 
         $midnightInTimezone = date('H', $dateInTimezone->getTimestamp());
-        $hoursDifference    = (24 - $midnightInTimezone) % 24;
 
         if ($arbitraryDateInUTC->isEarlier($dateInTimezone)) {
-            $hoursDifference = -1 * $hoursDifference;
+            $hoursDifference = 0 - $midnightInTimezone;
+        } else {
+            $hoursDifference = 24 - $midnightInTimezone;
         }
 
+        $hoursDifference  = $hoursDifference % 24;
+
         $rescheduledTime += (3600 * $hoursDifference);
 
         if ($this->getTime() > $rescheduledTime) {
diff --git a/tests/PHPUnit/Core/ScheduledTime/DailyTest.php b/tests/PHPUnit/Core/ScheduledTime/DailyTest.php
index c825cbfb6f..a63302cffc 100644
--- a/tests/PHPUnit/Core/ScheduledTime/DailyTest.php
+++ b/tests/PHPUnit/Core/ScheduledTime/DailyTest.php
@@ -101,7 +101,7 @@ class ScheduledTime_DailyTest extends PHPUnit_Framework_TestCase
 
         $mock->setTimezone('Pacific/Auckland');
         $timeAuckland = $mock->getRescheduledTime();
-        $this->assertEquals(-11 * $oneHourInSeconds, $timeAuckland - $timeUTC);
+        $this->assertEquals(-13 * $oneHourInSeconds, $timeAuckland - $timeUTC);
 
 
         $mock->setTimezone('America/Los_Angeles');
diff --git a/tests/PHPUnit/Core/ScheduledTime/MonthlyTest.php b/tests/PHPUnit/Core/ScheduledTime/MonthlyTest.php
index 5c837cdd31..2f26d083c3 100644
--- a/tests/PHPUnit/Core/ScheduledTime/MonthlyTest.php
+++ b/tests/PHPUnit/Core/ScheduledTime/MonthlyTest.php
@@ -112,7 +112,7 @@ class ScheduledTime_MonthlyTest extends PHPUnit_Framework_TestCase
 
         $mock->setTimezone('Pacific/Auckland');
         $timeAuckland = $mock->getRescheduledTime();
-        $this->assertEquals(-11 * $oneHourInSeconds, $timeAuckland - $timeUTC);
+        $this->assertEquals(-13 * $oneHourInSeconds, $timeAuckland - $timeUTC);
 
 
         $mock->setTimezone('America/Los_Angeles');
diff --git a/tests/PHPUnit/Core/ScheduledTime/WeeklyTest.php b/tests/PHPUnit/Core/ScheduledTime/WeeklyTest.php
index ecf5bbaf58..46bf3725cc 100644
--- a/tests/PHPUnit/Core/ScheduledTime/WeeklyTest.php
+++ b/tests/PHPUnit/Core/ScheduledTime/WeeklyTest.php
@@ -148,7 +148,7 @@ class ScheduledTime_WeeklyTest extends PHPUnit_Framework_TestCase
 
         $mock->setTimezone('Pacific/Auckland');
         $timeAuckland = $mock->getRescheduledTime();
-        $this->assertEquals(-11 * $oneHourInSeconds, $timeAuckland - $timeUTC);
+        $this->assertEquals(-13 * $oneHourInSeconds, $timeAuckland - $timeUTC);
 
 
         $mock->setTimezone('America/Los_Angeles');
-- 
GitLab