Revision: 2501
https://sourceforge.net/p/mrbs/code/2501/
Author: cimorrison
Date: 2012-10-15 15:40:33 +0000 (Mon, 15 Oct 2012)
Log Message:
-----------
Restructured code
Modified Paths:
--------------
mrbs/branches/improved_repeat_interface/web/functions.inc
mrbs/branches/improved_repeat_interface/web/functions_view.inc
Modified: mrbs/branches/improved_repeat_interface/web/functions.inc
===================================================================
--- mrbs/branches/improved_repeat_interface/web/functions.inc 2012-10-15
15:25:18 UTC (rev 2500)
+++ mrbs/branches/improved_repeat_interface/web/functions.inc 2012-10-15
15:40:33 UTC (rev 2501)
@@ -392,12 +392,21 @@
}
+// Convert an RFC 5545 day to an ordinal number representing the day of the
week,
+// eg "MO" returns "1"
+function RFC_5545_day_to_ord($day)
+{
+ global $RFC_5545_days;
+
+ $tmp = array_keys($RFC_5545_days, $day);
+ return $tmp[0];
+}
+
+
// Converts a BYDAY (eg "2SU") value for a given year and month into a
// day of the month
function byday_to_day($year, $month, $byday)
{
- global $RFC_5545_days;
-
// First of all normalise the month and year, as we allow $month > 12
while ($month > 12)
{
@@ -411,8 +420,7 @@
// Get the starting day of the week
$start_dow = date('w', mktime(0, 0, 0, $month, $start_dom, $year));
// Turn the BYDAY day of the week into an integer
- $tmp = array_keys($RFC_5545_days, $dow);
- $byday_dow = $tmp[0];
+ $byday_dow = RFC_5545_day_to_ord($dow);
// get the difference in days
$diff = $byday_dow - $start_dow;
$diff += ($ord > 0) ? 7 : -7;
Modified: mrbs/branches/improved_repeat_interface/web/functions_view.inc
===================================================================
--- mrbs/branches/improved_repeat_interface/web/functions_view.inc
2012-10-15 15:25:18 UTC (rev 2500)
+++ mrbs/branches/improved_repeat_interface/web/functions_view.inc
2012-10-15 15:40:33 UTC (rev 2501)
@@ -41,7 +41,6 @@
global $strftime_format;
global $tbl_entry;
global $select_options;
- global $RFC_5545_days;
// Get the duration if we haven't got it already
if (!isset($data['duration']))
@@ -226,8 +225,7 @@
// to sort out. It assumes all languages have the same order as
English
// eg "the second Wednesday" which is probably not true.
list($ord, $dow) = byday_split($data['month_relative']);
- $tmp = array_keys($RFC_5545_days, $dow);
- $value = get_vocab("ord_" . $ord) . " " . day_name($tmp[0]);
+ $value = get_vocab("ord_" . $ord) . " " .
day_name(RFC_5545_day_to_ord($dow));
}
else
{
------------------------------------------------------------------------------
Don't let slow site performance ruin your business. Deploy New Relic APM
Deploy New Relic app performance management and know exactly
what is happening inside your Ruby, Python, PHP, Java, and .NET app
Try New Relic at no cost today and get our sweet Data Nerd shirt too!
http://p.sf.net/sfu/newrelic-dev2dev
_______________________________________________
Mrbs-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mrbs-commits