From cf142e47b3f8177d7f81bf16bab125cd2a51367b Mon Sep 17 00:00:00 2001 From: "Donald A. Lobo" Date: Sun, 5 May 2013 08:48:06 -0700 Subject: [PATCH] CRM-12526 ---------------------------------------- * CRM-12526: getUTCTime ignores format parameter http://issues.civicrm.org/jira/browse/CRM-12526 --- CRM/Contact/BAO/GroupContactCache.php | 4 ++-- CRM/Utils/Date.php | 11 ++++++++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/CRM/Contact/BAO/GroupContactCache.php b/CRM/Contact/BAO/GroupContactCache.php index e9a7345607..1a2f68c6cb 100644 --- a/CRM/Contact/BAO/GroupContactCache.php +++ b/CRM/Contact/BAO/GroupContactCache.php @@ -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) { diff --git a/CRM/Utils/Date.php b/CRM/Utils/Date.php index e0604fc118..82ffc3b47f 100644 --- a/CRM/Utils/Date.php +++ b/CRM/Utils/Date.php @@ -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; -- 2.25.1