Revision: 1807
          http://mrbs.svn.sourceforge.net/mrbs/?rev=1807&view=rev
Author:   cimorrison
Date:     2011-03-27 22:14:24 +0000 (Sun, 27 Mar 2011)

Log Message:
-----------
Fixed a problem whereby the range of the time selectors was an hour out if you 
tried to make a booking for a DST changeover day (the booking was being made 
for the requested time, but the selectors prevented you from choosing the 
first/last hour of the booking day).   [ In the process also removed a couple 
of instances of the use of the deprecated is_dst parameter to mktime() ]

Modified Paths:
--------------
    mrbs/trunk/web/edit_entry.php
    mrbs/trunk/web/edit_entry_handler.php

Modified: mrbs/trunk/web/edit_entry.php
===================================================================
--- mrbs/trunk/web/edit_entry.php       2011-03-26 15:04:06 UTC (rev 1806)
+++ mrbs/trunk/web/edit_entry.php       2011-03-27 22:14:24 UTC (rev 1807)
@@ -53,7 +53,11 @@
 
 // Generate a time or period selector starting with $first and ending with 
$last.
 // $time is a full Unix timestamp and is the current value.  The selector 
returns
-// the start time in seconds since the beginning of the day for the start of 
that slot
+// the start time in seconds since the beginning of the day for the start of 
that slot.
+// Note that these are nominal seconds and do not take account of any DST 
changes that
+// may have happened earlier in the day.  (It's this way because we don't know 
what day
+// it is as that's controlled by the date selector - and we can't assume that 
we have
+// JavaScript enabled to go and read it)
 // The $display parameter sets the display style of the <select>
 function genslotselector($area, $prefix, $first, $last, $time, 
$display="block")
 {
@@ -74,8 +78,11 @@
   // that there is only one select passing through the variable to the handler
   $disabled = (strtolower($display) == "none") ? " disabled=\"disabled\"" : "";
   
+  // Get the current hour and minute and convert it into nominal (ie ignoring 
any
+  // DST effects) seconds since the start of the day
   $date = getdate($time);
-  $time_zero = mktime(0, 0, 0, $date['mon'], $date['mday'], $date['year']);
+  $current_t = (($date['hours'] * 60) + $date['minutes']) * 60;
+  
   if ($enable_periods)
   {
     $base = 12*60*60;  // The start of the first period of the day
@@ -87,10 +94,13 @@
   $html .= "<select style=\"display: $display\" id = 
\"${prefix}seconds${area['id']}\" name=\"${prefix}seconds\" 
onChange=\"adjustSlotSelectors(this.form)\"$disabled>\n";
   for ($t = $first; $t <= $last; $t = $t + $resolution)
   {
-    $timestamp = $t + $time_zero;
+    // The date used below is completely arbitrary.   All that matters is that 
it
+    // is a day that does not contain a DST boundary.   (We need a real date 
so that
+    // we can use strftime to get an hour and minute formatted according to 
the locale)
+    $timestamp = $t + mktime(0, 0, 0, 1, 1, 2000);
     $slot_string = ($enable_periods) ? $periods[intval(($t-$base)/60)] : 
utf8_strftime($format, $timestamp);
     $html .= "<option value=\"$t\"";
-    $html .= ($timestamp == $time) ? " selected=\"selected\"" : "";
+    $html .= ($t == $current_t) ? " selected=\"selected\"" : "";
     $html .= ">$slot_string</option>\n";
   }
   $html .= "</select>\n";

Modified: mrbs/trunk/web/edit_entry_handler.php
===================================================================
--- mrbs/trunk/web/edit_entry_handler.php       2011-03-26 15:04:06 UTC (rev 
1806)
+++ mrbs/trunk/web/edit_entry_handler.php       2011-03-27 22:14:24 UTC (rev 
1807)
@@ -293,12 +293,10 @@
 }
 
 // Now work out the start and times
-$starttime = mktime(0, 0, 0,
-                    $month, $day, $year,
-                    is_dst($month, $day, $year, intval($start_seconds/3600))) 
+ $start_seconds;
-$endtime   = mktime(0, 0, 0,
-                    $end_month, $end_day, $end_year,
-                    is_dst($end_month, $end_day, $end_year, 
intval($end_seconds/3600))) + $end_seconds;
+$starttime = mktime(intval($start_seconds/3600), 
intval(($start_seconds%3600)/60), 0,
+                    $month, $day, $year);
+$endtime   = mktime(intval($end_seconds/3600), intval(($end_seconds%3600)/60), 
0,
+                    $end_month, $end_day, $end_year);
 // If we're using periods then the endtime we've been returned by the form is 
actually
 // the beginning of the last period in the booking (it's more intuitive for 
users this way)
 // so we need to add on 60 seconds (1 period)
@@ -344,7 +342,8 @@
     isset($rep_end_month) && isset($rep_end_day) && isset($rep_end_year))
 {
   // Get the repeat entry settings
-  $end_date = $start_seconds + mktime(0, 0, 0, $rep_end_month, $rep_end_day, 
$rep_end_year);
+  $end_date = mktime(intval($start_seconds/3600), 
intval(($start_seconds%3600)/60), 0,
+                     $rep_end_month, $rep_end_day, $rep_end_year);
 }
 else
 {


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

------------------------------------------------------------------------------
Enable your software for Intel(R) Active Management Technology to meet the
growing manageability and security demands of your customers. Businesses
are taking advantage of Intel(R) vPro (TM) technology - will your software 
be a part of the solution? Download the Intel(R) Manageability Checker 
today! http://p.sf.net/sfu/intel-dev2devmar
_______________________________________________
Mrbs-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mrbs-commits

Reply via email to