Changeset:
        1a178d511adc
        
https://sourceforge.net/p/mrbs/hg-code/ci/1a178d511adc6d0713a87b42da2339690d0ee1d4
Author:
        Campbell Morrison <cimorri...@hg.code.sf.net>
Date:
        Wed Mar 15 09:20:34 2017 +0000
Log message:

Changed calculation of whether a day is a weeekend day to use $working_days,
instead of Saturday and Sunday, to allow for locales, eg Saudi Arabia, where
the weekend does not fall on Sat and Sun.

diffstat:

 web/functions.inc |  21 ++++++++++++++++++++-
 web/mincals.inc   |  25 ++++++++++++-------------
 2 files changed, 32 insertions(+), 14 deletions(-)

diffs (88 lines):

diff -r f279a0acaebb -r 1a178d511adc web/functions.inc
--- a/web/functions.inc Wed Mar 15 00:03:42 2017 +0000
+++ b/web/functions.inc Wed Mar 15 09:20:34 2017 +0000
@@ -2785,13 +2785,32 @@
   return (int) $diff;
 }
 
+
 // checks whether a given day of the week is supposed to be hidden in the 
display
-function is_hidden_day ($dow)
+function is_hidden_day($dow)
 {
   global $hidden_days;
+  
   return (isset($hidden_days) && in_array($dow, $hidden_days));
 }
 
+
+// checks whether a given day of the week is a weekend day
+function is_weekend($dow)
+{
+  global $working_days;
+  
+  // We are using $working_days to define weekdays and therefore weekend
+  // days. This may not be correct as people might want to define a weekend
+  // day (eg Saturday) to be a working day.
+  
+  // An alternative could be to use IntlCalendar::getDayOfWeekType(), but
+  // that isn't available on all systems.
+  
+  return !in_array($dow, $working_days);
+}
+
+
 // returns true if event should be considered private based on
 // config settings and event's privacy status (passed to function)
 function is_private_event($privacy_status) 
diff -r f279a0acaebb -r 1a178d511adc web/mincals.inc
--- a/web/mincals.inc   Wed Mar 15 00:03:42 2017 +0000
+++ b/web/mincals.inc   Wed Mar 15 09:20:34 2017 +0000
@@ -139,10 +139,9 @@
       }
       for ($i = 0; $i < 7; $i++)
       {
-        $currentday = gmmktime (12, 0, 0, $this->month, $d, $this->year);
-        $baseclass = ((date('w', $currentday) == 0) ||
-                      (date('w', $currentday) == 6)) ? "day_weekend" : 
"day_weekday";
-        $hide_this_day = is_hidden_day(($i + $weekstarts) % 7);
+        $day_of_week = ($i + $weekstarts) % 7;
+        $baseclass = is_weekend($day_of_week) ? "day_weekend" : "day_weekday";
+        $hide_this_day = is_hidden_day($day_of_week);
 
         if ($hide_this_day)
         {
@@ -309,24 +308,24 @@
   {
     global $weekstarts, $strftime_format;
 
-    $basetime = mktime(12,0,0,6,11+$weekstarts,2000);
+    $basetime = mktime(12, 0, 0, 6, 11+$weekstarts, 2000);
+    
     for ($i = 0, $s = ""; $i < 7; $i++)
     {
       $show = $basetime + ($i * SECONDS_PER_DAY);
       $fl = utf8_strftime($strftime_format['dayname_cal'], $show);
-      $baseclass = ((date('w', $show) == 0) ||
-                    (date('w', $show) == 6)) ? "day_weekend" : "day_weekday";
+      $day_of_week = ($i + $weekstarts) % 7;
+      $baseclass = is_weekend($day_of_week) ? "day_weekend" : "day_weekday";
 
       // add a class if it's a hidden day so that we can apply special styling
-      if (is_hidden_day(($i + $weekstarts) % 7))
+      if (is_hidden_day($day_of_week))
       {
-        $s .= "<th class=\"$baseclass hidden\">$fl</th>\n";
+        $baseclass .= " hidden";
       }
-      else
-      {
-        $s .= "<th class=\"$baseclass\">$fl</th>\n";
-      }
+      
+      $s .= "<th class=\"$baseclass\">$fl</th>\n";
     }
+    
     return $s;
   }
   

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Mrbs-commits mailing list
Mrbs-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mrbs-commits

Reply via email to