Skip to content

Remove custom date filter#2127

Closed
jarednova wants to merge 5 commits into2.xfrom
2104/deprecate_date
Closed

Remove custom date filter#2127
jarednova wants to merge 5 commits into2.xfrom
2104/deprecate_date

Conversation

@jarednova
Copy link
Copy Markdown
Member

@jarednova jarednova commented Dec 24, 2019

Ticket: #2104

Issue

As @columbian-chris points out, there's some weird stuff happening when you use the date filter in certain circumstances. No wonder! We're overriding Twig's default behavior here in an attempt to better integrate WP behavior

Solution

Change the name of our custom filter from date ==> intl_date

Impact

This could break backwards compatibility, so making this a 2.x change

Usage Changes

Yes! Documented in the 2.x upgrade guide

Considerations

Should the name of the filter simply be date_i18n? My fear is unless we're taking exactly the WP behavior, we shouldn't have the same name — thus, intl_date is custom to Timber but something we can control even if in the future WP, Twig or PHP adopts new date/time internationalization behaviors.

Testing

Existing tests will need to be updated to match default Twig date filter behavior

@jarednova jarednova changed the base branch from master to 2.x December 24, 2019 19:13
@jarednova jarednova changed the title 2104/deprecate date Remove custom date filter Dec 24, 2019
@jarednova jarednova added the 2.0 label Dec 24, 2019
@codecov
Copy link
Copy Markdown

codecov bot commented Dec 25, 2019

Codecov Report

❗ No coverage uploaded for pull request base (2.x@33e4c93). Click here to learn what that means.
The diff coverage is 100%.

Impacted file tree graph

@@          Coverage Diff           @@
##             2.x    #2127   +/-   ##
======================================
  Coverage       ?   95.82%           
  Complexity     ?     1526           
======================================
  Files          ?       49           
  Lines          ?     3904           
  Branches       ?        0           
======================================
  Hits           ?     3741           
  Misses         ?      163           
  Partials       ?        0
Impacted Files Coverage Δ Complexity Δ
lib/Twig.php 97.76% <100%> (ø) 53 <0> (?)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 33e4c93...d6a13f5. Read the comment docs.

@gchtr
Copy link
Copy Markdown
Member

gchtr commented Dec 25, 2019

@jarednova I have some thoughts about this and I started working on a separate guide to document how we should work with dates in Timber. I will have some spare time during my holidays to finish that guide and think about a solution for when to use the new wp_date() function and when to still use date_i18n().

@jarednova
Copy link
Copy Markdown
Member Author

sounds good @gchtr! I'll cool my jets on this for now then

@jarednova
Copy link
Copy Markdown
Member Author

Closing in favor of #2135

@jarednova jarednova closed this Jan 5, 2020
@nlemoine nlemoine deleted the 2104/deprecate_date branch June 23, 2022 09:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants