You can use this script to fix the data. Name it whatever you want and place it in the root of your phpScheduleIt installation. Full instructions are in the comments.
<?php
/**
* Daylight savings time (DST) patch for USA DST adjustment
* @author Nick Korbel <lqqkout13@users.sourceforge.net>
* @version 03-11-07
* @package phpScheduleIt
*/
/**
* TO USE:
* 1) Back up your data
* 2) Place this file in the root of your phpScheduleIt installation
* 3) Browse to this file from your web browser
* 4) Delete this file
*/
/**
* Please refer to readme.html and LICENSE for any additional information
*
* Copyright (C) 2003 - 2006 phpScheduleIt
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the
* Free Software Foundation, Inc.
* 59 Temple Place
* Suite 330
* Boston, MA
* 02111-1307
* USA
*/
require_once('lib/db/ScheduleDB.class.php');
$dbEngine = new DBEngine();
$db = $dbEngine->db;
$rs = $db->query('SELECT resid, start_date, end_date FROM reservations');
$AdjustmentResults = new AdjustmentResults();
while ($row = $rs->fetchRow())
{
$result = AdjustReservationDates($db, $row['resid'], $row['start_date'], $row['end_date']);
$AdjustmentResults->Add($result);
}
if ($AdjustmentResults->AnyAdjustments)
{
echo '<br/><br/>All date adjustments have been made. Please use the provided rollback queries if any problems are found with the adjustments made.<br/>';
echo '<pre>' . $AdjustmentResults->GetRollbackQueries() . '</pre>';
}
else
{
echo '<br/>No date adjustments were necessary.';
}
function AdjustReservationDates($db, $resid, $startDate, $endDate)
{
$adjustedStartDate = GetAdjustedDate($startDate);
$adjustedEndDate = GetAdjustedDate($endDate);
if ($adjustedStartDate != $startDate || $adjustedEndDate != $endDate)
{
echo sprintf('<br/>resid: %s will be adjusted.<br/>Start date is %s (%s).<br/>End date is %s (%s)', $resid, date('m-d-Y H:i:s', $startDate), $startDate, date('m-d-Y H:i:s', $endDate), $endDate);
echo sprintf('<br/>Start date should be %s (%s).<br/>End date should be %s (%s)<br/>', $resid, date('m-d-Y H:i:s', $adjustedStartDate), $adjustedStartDate, date('m-d-Y H:i:s', $adjustedEndDate), $adjustedEndDate);
$query = $db->prepare('UPDATE reservations SET start_date = ?, end_date = ? WHERE resid = ?');
$result = $db->execute($query, array($adjustedStartDate, $adjustedEndDate, $resid));
$rollbackQuery = "UPDATE reservations SET start_date = $startDate, end_date = $endDate WHERE resid = '$resid'\n";
if (DB::isError($result))
{
echo '<br/>ERROR: ' . $result->getMessage() . ' ' . $result->getDebugInfo() . '<br/>';
}
return new AdjustmentResult(true, $rollbackQuery);
}
return new AdjustmentResult(false, '');
}
function GetAdjustedDate($timestamp)
{
$adjustedStartDate = $timestamp;
$parts = getdate($timestamp);
$hours = $parts['hours'];
if ($hours != 0)
{
if ($hours > 16)
{
// Reservation was likely supposed to be for the next day
$adjustedDay = $parts['mday'] + 1;
$adjustedStartDate = mktime(0, 0, 0, $parts['mon'], $adjustedDay, $parts['year']);
}
else if ($hours < 8)
{
$adjustedStartDate = mktime(0, 0, 0, $parts['mon'], $parts['mday'], $parts['year']);
}
}
return $adjustedStartDate;
}
class AdjustmentResult
{
var $DateAdjusted = false;
var $RollbackQuery = '';
function AdjusmtmentResult($dateAdjusted, $rollbackQuery)
{
$this->DateAdjusted = $dateAdjusted;
$this->RollbackQuery = $rollbackQuery;
}
}
class AdjustmentResults
{
var $AnyAdjustments = false;
var $Results = array();
function Add($adjustmentResult)
{
if ($adjustmentResult->DateAdjusted)
{
$this->AnyAdjustments = true;
}
$Results[] = $adjustmentResult;
}
function GetRollbackQueries()
{
$queries = '';
foreach ($this->Results as $result)
{
$queries .= $result->RollbackQuery;
}
return $queries;
}
}
?>