Merge pull request #9135 from tschuettler/CRM-19424
[civicrm-core.git] / CRM / Utils / Date.php
index a53acb6cd1e6860b462560671c8728d7219f53bc..f04e3a04818c6413f93085fccf32d358e700fa31 100644 (file)
@@ -184,7 +184,7 @@ class CRM_Utils_Date {
       // set LC_TIME and build the arrays from locale-provided names
       // June 1st, 1970 was a Monday
       CRM_Core_I18n::setLcTime();
-      for ($i = $firstDay; count($days) < 7; $i = $i > 6 ? 0 : $i + 1) {
+      for ($i = $firstDay; count($days) < 7; $i = $i > 5 ? 0 : $i + 1) {
         $days[$i] = strftime('%a', mktime(0, 0, 0, 6, $i, 1970));
       }
     }
@@ -213,7 +213,7 @@ class CRM_Utils_Date {
       // set LC_TIME and build the arrays from locale-provided names
       // June 1st, 1970 was a Monday
       CRM_Core_I18n::setLcTime();
-      for ($i = $firstDay; count($days) < 7; $i = $i > 6 ? 0 : $i + 1) {
+      for ($i = $firstDay; count($days) < 7; $i = $i > 5 ? 0 : $i + 1) {
         $days[$i] = strftime('%A', mktime(0, 0, 0, 6, $i, 1970));
       }
     }
@@ -1886,4 +1886,20 @@ class CRM_Utils_Date {
     return $formattedDate;
   }
 
+  /**
+   * Function to return days of the month.
+   *
+   * @return array
+   */
+  public static function getCalendarDayOfMonth() {
+    $month = array();
+    for ($i = 1; $i <= 31; $i++) {
+      $month[$i] = $i;
+      if ($i == 31) {
+        $month[$i] = $i . ' / Last day of month';
+      }
+    }
+    return $month;
+  }
+
 }