[dev] Patch for correct time in kronolith

Jason Rust jrust at rustyparts.com
Tue May 13 17:00:17 PDT 2003


Attached is a patch which makes it so the current time is selected when
a user clicks on the add event link.  Before it was defaulting to
12:00am or 8:00am in some very rare cases.  This patch makes adding an
event a bit more outlook in the sense that the current time is already
selected for you.

-Jason

-- 
http://www.rustyparts.com/
ferrous oxidation
-------------- next part --------------
Index: addevent.php
===================================================================
RCS file: /repository/kronolith/addevent.php,v
retrieving revision 1.39
diff -u -r1.39 addevent.php
--- addevent.php	6 Jan 2003 23:20:21 -0000	1.39
+++ addevent.php	13 May 2003 23:51:25 -0000
@@ -19,7 +19,9 @@
     $month = Horde::getFormData('month', date('n'));
     $day = Horde::getFormData('mday', date('j'));
     $year = Horde::getFormData('year', date('Y'));
-    $timestamp = mktime(8, 0, 0, $month, $day, $year);
+    $hour = date('H');
+    $min = date('i');
+    $timestamp = mktime($hour, $min - ($min % 5), 0, $month, $day, $year);
 }
 
 $url = Horde::getFormData('url');
Index: menu.php
===================================================================
RCS file: /repository/kronolith/menu.php,v
retrieving revision 1.24
diff -u -r1.24 menu.php
--- menu.php	8 May 2003 22:52:44 -0000	1.24
+++ menu.php	13 May 2003 23:51:25 -0000
@@ -20,7 +20,9 @@
         $month = 1;
         $day = Kronolith::firstDayOfWeek($week, $year);
     }
-    $timestamp = mktime(0, 0, 0, $month, $day, $year);
+    $hour = date('H');
+    $min = date('i');
+    $timestamp = mktime($hour, $min - ($min % 5), 0, $month, $day, $year);
 }
 $append = "?timestamp=$timestamp";
 
Index: month.php
===================================================================
RCS file: /repository/kronolith/month.php,v
retrieving revision 1.113
diff -u -r1.113 month.php
--- month.php	3 Jan 2003 02:17:40 -0000	1.113
+++ month.php	13 May 2003 23:51:25 -0000
@@ -87,6 +87,8 @@
 } else {
    $currentCalendars = array(true); 
 }
+$hour = date('H');
+$min = date('i');
 foreach ($currentCalendars as $id => $cal) {
     if ($sidebyside) {
         echo '<tr>';
@@ -94,6 +96,7 @@
     $dayofweek = $startday;
     for ($day = 1; $day <= $daysInMonth; $day++) {
         $dayStamp = mktime(0, 0, 0, $month, $day, $year);
+        $timestamp = mktime($hour, $min - ($min % 5), 0, $month, $day, $year);
         $week = Kronolith::weekOfYear($day, $month, $year);
     
         if (($dayofweek % 7 == 0) && ($dayofweek != 0)) {
@@ -131,7 +134,7 @@
     
         if (Auth::getAuth() && !$print_view) {
             $url = Horde::addParameter(Horde::applicationUrl('addevent.php'),
-                                       'timestamp=' . $dayStamp);
+                                       'timestamp=' . $timestamp);
             $url = Horde::addParameter($url, 'url', Horde::selfURL(true));
             echo '<td width="14%">' . Horde::link($url, _("Create a New Event")) . Horde::img('new.gif', _("Create a New Event"), 'align="right"') . '</a></td>';
         }
@@ -163,10 +166,9 @@
         $dayofweek++;
     }
 }
-?>
 
-</tr></table>
-</td></tr></table>
-
-<?php
+echo '</tr></table>
+</td></tr>';
+echo Kronolith::buildCategoryLegend();
+echo '</table>';
 require KRONOLITH_TEMPLATES . '/common-footer.inc';


More information about the dev mailing list