[REF] Replace usage of smarty's date_filter to ensure we don't call strftime which...
authorSeamus Lee <seamuslee001@gmail.com>
Wed, 15 Jun 2022 03:20:20 +0000 (13:20 +1000)
committerSeamus Lee <seamuslee001@gmail.com>
Thu, 16 Jun 2022 07:45:44 +0000 (17:45 +1000)
Ensure start date format is the same

15 files changed:
CRM/Core/Smarty/plugins/modifier.crmDate.php
CRM/Utils/Date.php
templates/CRM/Activity/Calendar/ICal.tpl
templates/CRM/Contribute/Form/Contribution/Main.tpl
templates/CRM/Contribute/Form/Contribution/MembershipBlock.tpl
templates/CRM/Core/Calendar/ICal.tpl
templates/CRM/Core/Calendar/Rss.tpl
templates/CRM/Event/Form/Registration/EventInfoBlock.tpl
templates/CRM/Event/Form/Selector.tpl
templates/CRM/Event/Form/Task/Print.tpl
templates/CRM/Event/Page/EventInfo.tpl
templates/CRM/Event/Page/List.tpl
templates/CRM/Event/Page/UserDashboard.tpl
templates/CRM/common/l10n.js.tpl
templates/CRM/common/navigation.js.tpl

index 2a175bcfc0132a7c3ad1a6b53d690143fc019a5d..b81855ae948fb82319d6a559e7534b27acb386df 100644 (file)
@@ -60,7 +60,9 @@ function smarty_modifier_crmDate($dateString, ?string $dateFormat = NULL, bool $
       $config = CRM_Core_Config::singleton();
       $dateFormat = $config->dateformatTime;
     }
-
+    if (is_int($dateString)) {
+      return CRM_Utils_Date::customFormatTs($dateString, $dateFormat);
+    }
     return CRM_Utils_Date::customFormat($dateString, $dateFormat);
   }
   return '';
index 1bdabb2b60114330378b0ab278a3eb2719e876f4..a08e6b7d680fabd8b150cc59c2f79a29c678e9ee 100644 (file)
@@ -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);
@@ -433,6 +433,7 @@ class CRM_Utils_Date {
         '%A' => $type,
         '%Y' => $year,
         '%s' => str_pad($second, 2, 0, STR_PAD_LEFT),
+        '%S' => str_pad($second, 2, 0, STR_PAD_LEFT),
       ];
 
       return strtr($format, $date);
index 2ff0c050d2e9376448b18799c510b888d7cadcbf..b1c90b1f3f493194da511fc95462b94dfe527963 100644 (file)
@@ -16,7 +16,7 @@ BEGIN:VEVENT
 UID:CIVICRMACTIVITY{$activity->id}
 SUMMARY:{$activity->subject|crmICalText}
 CALSCALE:GREGORIAN
-DTSTAMP;TZID={$timezone}:{$smarty.now|date_format:'%Y-%m-%d %H:%M:%S'|crmICalDate}
+DTSTAMP;TZID={$timezone}:{$smarty.now|crmDate:'%Y-%m-%d %H:%M:%S'|crmICalDate}
 DTSTART;TZID={$timezone}:{$activity->activity_date_time|crmICalDate}
 DURATION:PT{$activity->duration}M
 {if $activity->location}
index d82d0af5357577cc66eb16dab7422a7333fea879..edd12f0f571e27d665634346e4fbb56228a695d2 100644 (file)
               {/if}
             {else}
               <div class="label">{$form.start_date.label}</div>
-              <div class="content">{$start_date_display|date_format}</div>
+              <div class="content">{$start_date_display|crmDate:'%b %e, %Y'}</div>
             {/if}
             <div class="clear"></div>
           </div>
index 372b69efe867bbdd04c0d850ab7e9675ed317564..51d6ab1abd85bd99dad3fa3e0d4647bdad4576f1 100644 (file)
@@ -37,7 +37,7 @@
                 <div id='help'>
                   {* Lifetime memberships have no end-date so current_membership array key exists but is NULL *}
                   {if $row.current_membership}
-                    {if $row.current_membership|date_format:"%Y%m%d" LT $smarty.now|date_format:"%Y%m%d"}
+                    {if $row.current_membership|crmDate:"%Y%m%d" LT $smarty.now|crmDate:"%Y%m%d"}
                       {ts 1=$row.current_membership|crmDate 2=$row.name}Your <strong>%2</strong> membership expired on %1.{/ts}<br />
                     {else}
                       {ts 1=$row.current_membership|crmDate 2=$row.name}Your <strong>%2</strong> membership expires on %1.{/ts}<br />
             {* Check if there is an existing membership of this type (current_membership NOT empty) and if the end-date is prior to today. *}
             {if array_key_exists( 'current_membership', $row ) AND $context EQ "makeContribution" }
               {if $row.current_membership}
-                {if $row.current_membership|date_format:"%Y%m%d" LT $smarty.now|date_format:"%Y%m%d"}
+                {if $row.current_membership|crmDate:"%Y%m%d" LT $smarty.now|crmDate:"%Y%m%d"}
                   <br /><em>{ts 1=$row.current_membership|crmDate 2=$row.name}Your <strong>%2</strong> membership expired on %1.{/ts}</em>
                 {else}
                   <br /><em>{ts 1=$row.current_membership|crmDate 2=$row.name}Your <strong>%2</strong> membership expires on %1.{/ts}</em>
index f38502d5adf5f9c895a6dfdb22b8260b61dd0ef0..3db616c76c5932b18fbc620777451533fa34abbb 100644 (file)
@@ -27,7 +27,7 @@ CALSCALE:GREGORIAN
 DTSTAMP;TZID={$timezone}:{$event.start_date|crmICalDate}
 DTSTART;TZID={$timezone}:{$event.start_date|crmICalDate}
 {else}
-DTSTAMP;TZID={$timezone}:{$smarty.now|date_format:'%Y-%m-%d %H:%M:%S'|crmICalDate}
+DTSTAMP;TZID={$timezone}:{$smarty.now|crmDate:'%Y-%m-%d %H:%M:%S'|crmICalDate}
 {/if}
 {if $event.end_date}
 DTEND;TZID={$timezone}:{$event.end_date|crmICalDate}
index cc0139f1d9e5994a546d176e0a0f9eb106764605..ffb5259b5fb5ae15537f7df4945d03b26bb3bfb2 100644 (file)
@@ -27,8 +27,8 @@
 {/if}
 {if $event.start_date}{ts}When{/ts}: {$event.start_date|crmDate}{if $event.end_date} {ts}through{/ts} {strip}
         {* Only show end time if end date = start date *}
-        {if $event.end_date|date_format:"%Y%m%d" == $event.start_date|date_format:"%Y%m%d"}
-            {$event.end_date|date_format:"%I:%M %p"}
+        {if $event.end_date|crmDate:"%Y%m%d" == $event.start_date|crmDate:"%Y%m%d"}
+            {$event.end_date|crmDate:"%I:%M %p"}
         {else}
             {$event.end_date|crmDate}
         {/if}{/strip}
index 8a0486b4c22ce784fc9a7fd9c16a314c0e304105..c75be4e1d365573a5815888c4d737b8795f21db8 100644 (file)
@@ -24,7 +24,7 @@
         {if $event.event_end_date}
             &nbsp; {ts}through{/ts} &nbsp;
             {* Only show end time if end date = start date *}
-            {if $event.event_end_date|date_format:"%Y%m%d" == $event.event_start_date|date_format:"%Y%m%d"}
+            {if $event.event_end_date|crmDate:"%Y%m%d" == $event.event_start_date|crmDate:"%Y%m%d"}
                 {$event.event_end_date|crmDate:0:1}
             {else}
                 {$event.event_end_date|crmDate}
index a09a6d3567c6c9dc0f9d51d732644105bf1c40bf..1461fc4d531d28b4acf79791dda12f0dc64de79f 100644 (file)
@@ -60,7 +60,7 @@
     <td class="right nowrap crm-participant-participant_fee_amount">{$row.participant_fee_amount|crmMoney:$row.participant_fee_currency}</td>
     <td class="crm-participant-participant_register_date">{$row.participant_register_date|truncate:10:''|crmDate}</td>
     <td class="crm-participant-event_start_date">{$row.event_start_date|truncate:10:''|crmDate}
-        {if $row.event_end_date && $row.event_end_date|date_format:"%Y%m%d" NEQ $row.event_start_date|date_format:"%Y%m%d"}
+        {if $row.event_end_date && $row.event_end_date|crmDate:"%Y%m%d" NEQ $row.event_start_date|crmDate:"%Y%m%d"}
             <br/>- {$row.event_end_date|truncate:10:''|crmDate}
         {/if}
    </td>
index 013cf6fd28a31913babfee65ee6192a90f474b71..689580967b0044861ac459262566a48f38a32531 100644 (file)
@@ -43,7 +43,7 @@
         {/if}
         <td class="crm-event-print-event_participant_fee_amount">{$row.participant_fee_amount|crmMoney}</td>
         <td class="crm-event-print-event_date">{$row.event_start_date|truncate:10:''|crmDate}
-          {if $row.event_end_date && $row.event_end_date|date_format:"%Y%m%d" NEQ $row.event_start_date|date_format:"%Y%m%d"}
+          {if $row.event_end_date && $row.event_end_date|crmDate:"%Y%m%d" NEQ $row.event_start_date|crmDate:"%Y%m%d"}
               <br/>- {$row.event_end_date|truncate:10:''|crmDate}
           {/if}
         </td>
index 8315c22131c0746a87127aca0fa6b557a571447d..55efe2c6ae140dca76564910fd20069b373f7a97 100644 (file)
             {if $event.event_end_date}
                 &nbsp;{ts}through{/ts}&nbsp;
                 {* Only show end time if end date = start date *}
-                {if $event.event_end_date|date_format:"%Y%m%d" == $event.event_start_date|date_format:"%Y%m%d"}
+                {if $event.event_end_date|crmDate:"%Y%m%d" == $event.event_start_date|crmDate:"%Y%m%d"}
                     {$event.event_end_date|crmDate:0:1}
                 {else}
                     {$event.event_end_date|crmDate}
index 50da60fd8b6d9caf50469bf443b98ad9379cbd1a..5d2d839ceb6bd8065a3daaba8a1a6fdb3605f07d 100644 (file)
@@ -32,7 +32,7 @@
         <td class="nowrap" data-order="{$event.start_date|crmDate:'%Y-%m-%d'}">
           {if $event.start_date}{$event.start_date|crmDate}{if $event.end_date}<br /><em>{ts}through{/ts}</em><br />{strip}
             {* Only show end time if end date = start date *}
-            {if $event.end_date|date_format:"%Y%m%d" == $event.start_date|date_format:"%Y%m%d"}
+            {if $event.end_date|crmDate:"%Y%m%d" == $event.start_date|crmDate:"%Y%m%d"}
               {$event.end_date|crmDate:0:1}
             {else}
               {$event.end_date|crmDate}
index 210ece0034e4f7b81e791b4aa31408a92e439b46..6ceeff6ad809d958b1707cc96f14c5dd8670c0f3 100644 (file)
@@ -31,7 +31,7 @@
                             {if $row.event_end_date}
                                 &nbsp; - &nbsp;
                                 {* Only show end time if end date = start date *}
-                                {if $row.event_end_date|date_format:"%Y%m%d" == $row.event_start_date|date_format:"%Y%m%d"}
+                                {if $row.event_end_date|crmDate:"%Y%m%d" == $row.event_start_date|crmDate:"%Y%m%d"}
                                     {$row.event_end_date|crmDate:0:1}
                                 {else}
                                     {$row.event_end_date|crmDate}
index 67f69ada05885bd537d3c64e5e5c4d627dfe5aac..03598223d76982dbd9ac3784f2e931bf70431613 100644 (file)
@@ -7,7 +7,7 @@
  | and copyright information, see https://civicrm.org/licensing       |
  +--------------------------------------------------------------------+
 *}// http://civicrm.org/licensing
-// <script> Generated {$smarty.now|date_format:'%d %b %Y %H:%M:%S'}
+// <script> Generated {$smarty.now|crmDate:'%d %b %Y %H:%M:%S'}
 {* This file should only contain strings and settings which rarely change *}
 (function($) {ldelim}
   // Config settings
index 5ec824a85e46250e75f26587a78cf8def7fabcc7..55594f6b9a11c7e5cbdf70815e7497c4b961e113 100644 (file)
@@ -28,7 +28,7 @@
       </li>
     {$navigation}
   </ul>
-{/strip}{/capture}// <script> Generated {$smarty.now|date_format:'%d %b %Y %H:%M:%S'}
+{/strip}{/capture}// <script> Generated {$smarty.now|crmDate:'%d %b %Y %H:%M:%S'}
 {literal}
 (function($) {
   var menuMarkup = {/literal}{$menuMarkup|@json_encode}{literal};