CRM-12526
authorDonald A. Lobo <lobo@civicrm.org>
Sun, 5 May 2013 15:48:06 +0000 (08:48 -0700)
committerDonald A. Lobo <lobo@civicrm.org>
Sun, 5 May 2013 15:48:06 +0000 (08:48 -0700)
----------------------------------------
* CRM-12526: getUTCTime ignores format parameter
  http://issues.civicrm.org/jira/browse/CRM-12526

CRM/Contact/BAO/GroupContactCache.php
CRM/Utils/Date.php

index e9a734560715234da1b7aed895bd2044946cab2e..1a2f68c6cb528a1fba5077d997e44076ff2ea435 100644 (file)
@@ -124,7 +124,7 @@ AND     ( g.cache_date IS NULL OR
 
     if (!empty($refreshGroupIDs)) {
       $refreshGroupIDString = CRM_Core_DAO::escapeString(implode(', ', $refreshGroupIDs));
-      $time  = CRM_Utils_Date::getUTCTime('YmdHis', $smartGroupCacheTimeout * 60);
+      $time  = CRM_Utils_Date::getUTCTime($smartGroupCacheTimeout * 60);
       $query = "
 UPDATE civicrm_group g
 SET    g.refresh_date = $time
@@ -233,7 +233,7 @@ WHERE  id IN ( $groupIDs )
     $smartGroupCacheTimeout = self::smartGroupCacheTimeout();
 
     $now         = CRM_Utils_Date::getUTCTime();
-    $refreshTime = CRM_Utils_Date::getUTCTime('YmdHis', $smartGroupCacheTimeout * 60);
+    $refreshTime = CRM_Utils_Date::getUTCTime($smartGroupCacheTimeout * 60);
 
     if (!isset($groupID)) {
       if ($smartGroupCacheTimeout == 0) {
index e0604fc118e76874f4bd9c277aef7b6427e2f3c0..82ffc3b47f462919f9e0682094fe190ed554e1d3 100644 (file)
@@ -1480,7 +1480,16 @@ class CRM_Utils_Date {
     return $format;
   }
 
-  static function getUTCTime($format = 'YmdHis', $offset = 0) {
+  /**
+   * Get the time in UTC for the current time. You can optionally send an offset from the current time if needed
+   *
+   * @param $offset int the offset from the current time in seconds
+   *
+   * @return the time in UTC
+   * @static
+   * @public
+   */
+  static function getUTCTime($offset = 0) {
     $originalTimezone = date_default_timezone_get();
     date_default_timezone_set('UTC');
     $time = time() + $offset;