phpcs fix
[civicrm-core.git] / CRM / Utils / Date.php
index 1c4dc6e03c260185836ea82494ccb7286d21b955..898045b7382518160cc144962c6637222e5f5a62 100644 (file)
@@ -3,7 +3,7 @@
   +--------------------------------------------------------------------+
   | CiviCRM version 4.6                                                |
   +--------------------------------------------------------------------+
-  | Copyright CiviCRM LLC (c) 2004-2014                                |
+  | Copyright CiviCRM LLC (c) 2004-2015                                |
   +--------------------------------------------------------------------+
   | This file is a part of CiviCRM.                                    |
   |                                                                    |
@@ -28,7 +28,7 @@
 /**
  *
  * @package CRM
- * @copyright CiviCRM LLC (c) 2004-2014
+ * @copyright CiviCRM LLC (c) 2004-2015
  * $Id$
  *
  */
@@ -166,7 +166,7 @@ class CRM_Utils_Date {
   }
 
   /**
-   * Return abbreviated weekday names according to the locale
+   * Return abbreviated weekday names according to the locale.
    *
    * @return array
    *   0-based array with abbreviated weekday names
@@ -187,7 +187,7 @@ class CRM_Utils_Date {
   }
 
   /**
-   * Return full weekday names according to the locale
+   * Return full weekday names according to the locale.
    *
    * @return array
    *   0-based array with full weekday names
@@ -208,7 +208,7 @@ class CRM_Utils_Date {
   }
 
   /**
-   * Return abbreviated month names according to the locale
+   * Return abbreviated month names according to the locale.
    *
    * @param bool $month
    *
@@ -233,7 +233,7 @@ class CRM_Utils_Date {
   }
 
   /**
-   * Return full month names according to the locale
+   * Return full month names according to the locale.
    *
    * @return array
    *   1-based array with full month names
@@ -272,7 +272,7 @@ class CRM_Utils_Date {
   }
 
   /**
-   * Create a date and time string in a provided format
+   * Create a date and time string in a provided format.
    *
    * %b - abbreviated month name ('Jan'..'Dec')
    * %B - full month name ('January'..'December')
@@ -710,7 +710,7 @@ class CRM_Utils_Date {
   }
 
   /**
-   * Get customized today
+   * Get customized today.
    *
    * This function is used for getting customized today. To get
    * actuall today pass 'dayParams' as null. or else pass the day,
@@ -727,7 +727,7 @@ class CRM_Utils_Date {
    *                             format is 2007-12-21 )
    *
    * @return string
-   *   Return the customized todays date (Y-m-d)
+   *   Return the customized today's date (Y-m-d)
    */
   public static function getToday($dayParams = NULL, $format = "Y-m-d") {
     if (is_null($dayParams) || empty($dayParams)) {
@@ -803,7 +803,7 @@ class CRM_Utils_Date {
   }
 
   /**
-   * Calculate Age in Years if greater than one year else in months
+   * Calculate Age in Years if greater than one year else in months.
    *
    * @param date $birthDate
    *   Birth Date.
@@ -958,7 +958,7 @@ class CRM_Utils_Date {
   }
 
   /**
-   * Resolves the given relative time interval into finite time limits
+   * Resolves the given relative time interval into finite time limits.
    *
    * @param array $relativeTerm
    *   Relative time frame like this, previous, etc.
@@ -1098,7 +1098,7 @@ class CRM_Utils_Date {
         switch ($relativeTerm) {
           case 'this':
             $from['Y'] = $fYear;
-            $fiscalYear = mktime(0, 0, 0, $from['M'], $form['d'], $from['Y'] + 1);
+            $fiscalYear = mktime(0, 0, 0, $from['M'], $from['d'] - 1, $from['Y'] + 1);
             $fiscalEnd = explode('-', date("Y-m-d", $fiscalYear));
 
             $to['d'] = $fiscalEnd['2'];
@@ -1108,7 +1108,7 @@ class CRM_Utils_Date {
 
           case 'previous':
             $from['Y'] = $fYear - 1;
-            $fiscalYear = mktime(0, 0, 0, $from['M'], $form['d'], $from['Y'] + 1);
+            $fiscalYear = mktime(0, 0, 0, $from['M'], $from['d'] - 1, $from['Y'] + 1);
             $fiscalEnd = explode('-', date("Y-m-d", $fiscalYear));
             $to['d'] = $fiscalEnd['2'];
             $to['M'] = $fiscalEnd['1'];
@@ -1117,7 +1117,7 @@ class CRM_Utils_Date {
 
           case 'next':
             $from['Y'] = $fYear + 1;
-            $fiscalYear = mktime(0, 0, 0, $from['M'], $from['d'], $from['Y'] + 1);
+            $fiscalYear = mktime(0, 0, 0, $from['M'], $from['d'] - 1, $from['Y'] + 1);
             $fiscalEnd = explode('-', date("Y-m-d", $fiscalYear));
             $to['d'] = $fiscalEnd['2'];
             $to['M'] = $fiscalEnd['1'];
@@ -1395,7 +1395,7 @@ class CRM_Utils_Date {
             $to['Y'] = $now['year'];
             $to['H'] = 23;
             $to['i'] = $to['s'] = 59;
-            $from = self::intervalAdd('month', -1, $to);
+            $from = self::intervalAdd('day', -30, $to);
             $from = self::intervalAdd('second', 1, $from);
             break;
 
@@ -1631,7 +1631,7 @@ class CRM_Utils_Date {
   }
 
   /**
-   * Calculate current fiscal year based on the fiscal month and day
+   * Calculate current fiscal year based on the fiscal month and day.
    *
    * @param int $fyDate
    *   Fiscal start date.
@@ -1691,7 +1691,7 @@ class CRM_Utils_Date {
   }
 
   /**
-   *  Function to convert mysql to date plugin format
+   *  Function to convert mysql to date plugin format.
    *
    * @param string $mysqlDate
    *   Date string.
@@ -1763,7 +1763,7 @@ class CRM_Utils_Date {
   }
 
   /**
-   * Function get date format
+   * Function get date format.
    *
    * @param string $formatType
    *   Date name e.g. birth.