#48934 closed enhancement (fixed)
Rework genitive month names in date output
Reported by: | Rarst | Owned by: | SergeyBiryukov |
---|---|---|---|
Milestone: | 5.4 | Priority: | normal |
Severity: | normal | Version: | |
Component: | Date/Time | Keywords: | has-patch has-unit-tests |
Focuses: | Cc: |
Description
WP historically does some post-processing on date output for locales that have genitive month names. This is implemented in wp_maybe_decline_date()
.
The standing implementation is quite brittle since it tried to guess necessary modifications from the output string. So, for example, digits representing year might be confused with digits representing day of months. There is no context to disambiguate.
Likely this needs to be reworked altogether.
The possible approaches are tentatively:
- Use the date format being processed to determine necessity of replacement.
- Work the logic into parser code that walks through the format and replaces formats with localized values.
Attachments (2)
Change History (9)
#1
@
5 years ago
- Keywords has-patch has-unit-tests added; needs-patch needs-unit-tests removed
- Milestone changed from Awaiting Review to 5.4
#2
follow-up:
↓ 3
@
5 years ago
A new parameter can't be non-optional for backwards compatibility. We are not in control of how third party code calls the function and that would crash it.
#3
in reply to:
↑ 2
@
5 years ago
Replying to Rarst:
A new parameter can't be non-optional for backwards compatibility. We are not in control of how third party code calls the function and that would crash it.
Good catch, 48934.2.diff checks if the format is passed and falls back to the current implementation otherwise.
As previously noted in comment:14:ticket:48606, the current implementation fails on formats like
F y
, whereМай 19
("May 19" in Russian) is assumed to be the 19th day of May and declined, while it's actually the 19th year (as in 2019).Since
wp_maybe_decline_date()
is no longer just a filter ondate_i18n
and is now called directly fromwp_date()
as a result of [45901], we can pass the date format to it to determine the necessity of replacement, instead of trying to guess the format without any context.48934.diff implements that and adds a new test case.