Revision: 1292
http://mrbs.svn.sourceforge.net/mrbs/?rev=1292&view=rev
Author: cimorrison
Date: 2010-02-08 12:37:20 +0000 (Mon, 08 Feb 2010)
Log Message:
-----------
Fixed incorrect reporting of durations in email notifications (both when using
periods and not). Bug reported by Colin Napier.
Modified Paths:
--------------
mrbs/trunk/web/edit_entry_handler.php
mrbs/trunk/web/functions.inc
Modified: mrbs/trunk/web/edit_entry_handler.php
===================================================================
--- mrbs/trunk/web/edit_entry_handler.php 2010-02-07 09:09:56 UTC (rev
1291)
+++ mrbs/trunk/web/edit_entry_handler.php 2010-02-08 12:37:20 UTC (rev
1292)
@@ -215,26 +215,16 @@
// Support locales where ',' is used as the decimal point
$duration = preg_replace('/,/', '.', $duration);
-if ( $enable_periods )
+if ($enable_periods)
{
$resolution = 60;
$hour = 12;
$minute = $period;
- $max_periods = count($periods);
- if ( $dur_units == "periods" && ($minute + $duration) > $max_periods )
- {
- $duration = (24*60*floor($duration/$max_periods)) +
- ($duration%$max_periods);
- }
- if ( $dur_units == "days" && $minute == 0 )
- {
- $dur_units = "periods";
- $duration = $max_periods + ($duration-1)*60*24;
- }
}
-// Convert the duration into seconds
-fromTimeString($duration, $dur_units);
+// Get the duration in seconds
+$dur_seconds = $duration;
+$enable_periods ? fromPeriodString($period, $dur_seconds, $dur_units) :
fromTimeString($dur_seconds, $dur_units);
if (isset($all_day) && ($all_day == "yes"))
@@ -276,7 +266,7 @@
is_dst($month, $day, $year, $hour));
$endtime = mktime($hour, $minute, 0,
$month, $day, $year,
- is_dst($month, $day, $year, $hour)) + $duration;
+ is_dst($month, $day, $year, $hour)) + $dur_seconds;
// Round down the starttime and round up the endtime to the nearest slot
boundaries
$am7=mktime($morningstarts,$morningstarts_minutes,0,
Modified: mrbs/trunk/web/functions.inc
===================================================================
--- mrbs/trunk/web/functions.inc 2010-02-07 09:09:56 UTC (rev 1291)
+++ mrbs/trunk/web/functions.inc 2010-02-08 12:37:20 UTC (rev 1292)
@@ -186,7 +186,6 @@
function toPeriodString($start_period, &$dur, &$units)
{
- global $enable_periods;
global $periods;
$max_periods = count($periods);
@@ -223,8 +222,43 @@
}
}
+// Converts a period of $units starting at $start_period into seconds, when it
is
+// originally expressed in $dur_units (periods or days). (Almost the inverse
of
+// toPeriodString(), but note that toPeriodString() does language translation)
+function fromPeriodString($start_period, &$units, $dur_units)
+{
+ global $periods;
+
+ if (!isset($units) || !isset($dur_units))
+ {
+ return;
+ }
+
+ // First get the duration in minutes
+ $max_periods = count($periods);
+ if ($dur_units == "periods" && ($start_period + $units) > $max_periods)
+ {
+ $units = (24*60*floor($units/$max_periods)) + ($units%$max_periods);
+ }
+ if ($dur_units == "days")
+ {
+ if ($start_period == 0)
+ {
+ $units = $max_periods + ($units-1)*60*24;
+ }
+ else
+ {
+ $units = $units * 60 * 24;
+ }
+ }
+
+ // Then convert into seconds
+ $units = (int) $units;
+ $units = 60 * $units;
+}
+
function genDateSelector($prefix, $day, $month, $year)
{
if($day == 0)
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
_______________________________________________
Mrbs-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mrbs-commits