From 0bb94e15b56ef4797cd9db1d05f8ead8f28de28b Mon Sep 17 00:00:00 2001 From: Seamus Lee Date: Thu, 16 Jun 2022 17:49:51 +1000 Subject: [PATCH] [REF] Fix second output in customFormat function and extend unit test --- CRM/Utils/Date.php | 2 +- tests/phpunit/CRM/Utils/DateTest.php | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CRM/Utils/Date.php b/CRM/Utils/Date.php index 1bdabb2b60..1d88eb6f7c 100644 --- a/CRM/Utils/Date.php +++ b/CRM/Utils/Date.php @@ -369,7 +369,7 @@ class CRM_Utils_Date { $hour24 = (int) substr($dateString, 11, 2); $minute = (int) substr($dateString, 14, 2); - $second = (int) substr($dateString, 16, 2); + $second = (int) substr($dateString, 17, 2); } else { $year = (int) substr($dateString, 0, 4); diff --git a/tests/phpunit/CRM/Utils/DateTest.php b/tests/phpunit/CRM/Utils/DateTest.php index 8ab957fbbe..b68f1b39b8 100644 --- a/tests/phpunit/CRM/Utils/DateTest.php +++ b/tests/phpunit/CRM/Utils/DateTest.php @@ -270,6 +270,7 @@ class CRM_Utils_DateTest extends CiviUnitTestCase { $this->assertEquals(CRM_Utils_Date::customFormat($dateTime, "%p"), "pm"); $this->assertEquals(CRM_Utils_Date::customFormat($dateTime, "%P"), "PM"); $this->assertEquals(CRM_Utils_Date::customFormat($dateTime, "%Y"), "2018"); + $this->assertEquals(CRM_Utils_Date::customFormat($dateTime, "%s"), "44"); } /** -- 2.25.1