Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[REF][PHP8.1] Replace usage of the date_format modifer with crmDate t… #24008

Merged
merged 1 commit into from
Jul 29, 2022

Conversation

seamuslee001
Copy link
Contributor

…o resolve issues with strftime

Overview

This is like #23800 but for message_templates

Before

date_format modifier used triggering strftime deprecations

After

crmDate modifier used and less deprecations

ping @eileenmcnaughton @totten @demeritcowboy @colemanw

@civibot civibot bot added the master label Jul 18, 2022
@civibot
Copy link

civibot bot commented Jul 18, 2022

(Standard links)

@@ -25,7 +25,7 @@
{/if}

<p>Your order number is #{$transaction_id}. {if !empty($line_items) && empty($is_refund)} Information about the workshops will be sent separately to each participant.{/if}
Here's a summary of your transaction placed on {$transaction_date|date_format:"%D %I:%M %p %Z"}:</p>
Here's a summary of your transaction placed on {$transaction_date|crmDate:"%D %I:%M %p %Z"}:</p>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very different.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See above about %Z. Otherwise there's a minor difference now but unlikely to be a problem. Previously: "Eastern Daylight Time", now: "EDT". And am/pm vs AM/PM.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@demeritcowboy ok so the lower case AM/PM might be a thing but the timezone to me looks like it as always meant to be abbreviation as per https://www.php.net/manual/en/function.strftime.php note it is capital Z

Copy link
Contributor

@demeritcowboy demeritcowboy Jul 28, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah ok I'm not too worried about this difference. It's more that date('T') will give the wrong zone half (quarter?) the time since it is always based on "now" (because of pesky Daylight Saving).

@eileenmcnaughton
Copy link
Contributor

FWIW most of these changes are in places where I intend to swap out the smarty vars for tokens. I haven't been putting up much on that work cos the open PR hasn't been getting much traction but those legacy date formatting calls will all 'naturally' disappear as I work through making the templates previewable

@seamuslee001
Copy link
Contributor Author

I have brought in my changes from the #24032 PR and also have applied some handling now for %D and %Z

@seamuslee001
Copy link
Contributor Author

@demeritcowboy now with the other PR merged does this seem better to you now?

'%s' => str_pad($second, 2, 0, STR_PAD_LEFT),
'%S' => str_pad($second, 2, 0, STR_PAD_LEFT),
'%Z' => date('T'),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to take the date being custom-format'd into account, since otherwise it always gives the timezone corresponding to "now".

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok updated to that now @demeritcowboy good pick up

…o resolve issues with strftime

Add in handling for %D and %Z

pick up timezone based on date
@seamuslee001 seamuslee001 merged commit 2bfaf31 into civicrm:master Jul 29, 2022
@seamuslee001 seamuslee001 deleted the php8_1_message_templates branch July 29, 2022 00:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants