fix: format_P (%P) uses language-specific AM/PM values#115
Conversation
format_P in Generic.pm used a lexical @ampm array directly, so it always returned English "am"/"pm" regardless of language module. Same inheritance bug pattern as format_o (PR cpan-authors#107). Fix: delegate to format_p via method dispatch, which correctly resolves to the language module's copied format_p function. Affected languages with non-English AMPM: Dutch (VM/NM), Finnish (ap/ip), Hungarian (DE./DU.), Czech (dop./odp.), Chinese, Arabic, Greek, and 10+ others. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Greptile SummaryThis PR fixes a one-line bug in Confidence Score: 5/5This PR is safe to merge — minimal one-line fix with correct delegation and well-targeted tests. The fix is a clean, minimal delegation that correctly resolves the inheritance bug for all language modules. Test count arithmetic checks out (292 + 7 = 299), and the Dutch AM/PM cases verify both the regression scenario and the new behavior. No regressions for languages without a custom No files require special attention.
|
| Filename | Overview |
|---|---|
| lib/Date/Format/Generic.pm | One-line fix: format_P now delegates to format_p via method dispatch instead of accessing the lexical @AMPM array directly, fixing language-specific lowercase AM/PM. |
| t/format.t | Test count correctly updated from 292 to 299 (+7); adds English %P baseline and a Dutch section covering both PM (NM→nm) and AM (VM→vm) timestamps. |
Sequence Diagram
sequenceDiagram
participant C as Caller
participant G as Generic.pm
participant D as Dutch.pm
Note over C,D: %P format dispatch (after fix)
C->>G: format_P($obj)
G->>D: $obj->format_p()
D-->>G: "VM" or "NM"
G-->>C: lc("VM") → "vm"
Note over C,G: %P format dispatch (before fix)
C->>G: format_P($obj)
G->>G: lc($AMPM[...]) using Generic's @AMPM
G-->>C: "am" or "pm" (always English)
Reviews (1): Last reviewed commit: "fix: format_P (%P) now uses language-spe..." | Re-trigger Greptile
What
%P(lowercase am/pm) now returns the correct language-specific value instead of always returning English "am"/"pm".Why
format_PinGeneric.pmused the lexical@AMPMarray directly — same inheritance bug pattern asformat_o(#107). Language modules copyformat_pinto their own namespace (where it references the module's@AMPM), butformat_Pwas never copied, so it always fell through to Generic's English array.Affected languages: Dutch (VM/NM), Finnish (ap/ip), Hungarian (DE./DU.), Czech (dop./odp.), Chinese, Arabic, Greek, and 10+ others.
How
One-line fix: changed
format_Pfrom reimplementing the AM/PM logic with the lexical array to delegating via method dispatch ($_[0]->format_p), which correctly resolves to the language module's copiedformat_p.Testing
%Ptest to English baseline section%preturnsVM/NMand%Preturnsvm/nm🤖 Generated with Claude Code
Quality Report
Changes: 2 files changed, 12 insertions(+), 2 deletions(-)
Code scan: clean
Tests: skipped
Branch hygiene: clean
Generated by Kōan post-mission quality pipeline