feat: add %F and %u strftime format codes#111
Conversation
|
@Koan-Bot rebase |
Greptile SummaryThis PR adds two POSIX Confidence Score: 5/5Safe to merge — implementation is minimal, follows existing patterns exactly, and is thoroughly tested. Both new format functions are correct: format_u uses the idiomatic $_[0]->[6] || 7 pattern to remap Sunday from 0 to 7, and format_F composes existing helpers the same way format_D and format_T do. Inheritance means all 30+ language subclasses get the new codes for free. 15 new test cases cover every language fixture plus a dedicated Sunday boundary check. No P0 or P1 findings. No files require special attention.
|
| Filename | Overview |
|---|---|
| lib/Date/Format/Generic.pm | Adds format_u (Monday-based weekday, Sunday→7) and format_F (ISO 8601 YYYY-MM-DD); both follow existing patterns and are correctly implemented. |
| lib/Date/Format.pm | Documentation additions for %F and %u, plus correction of %e range from 1..32 to 1..31. |
| t/format.t | Adds 15 new test cases covering %F and %u across all 6 language sections plus a dedicated Sunday boundary test (315964800); test count updated from 292 to 307. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A["time2str / strftime call"] --> B["_subs() regex substitution\n%(O?[%a-zA-Z])"]
B --> C{Format code?}
C -->|"%F"| D["format_F()\nformat_Y . '-' . format_m . '-' . format_d\n→ YYYY-MM-DD"]
C -->|"%u"| E["format_u()\n$_[0]->[6] || 7\n→ 1..7, Sunday=7"]
C -->|"%w"| F["format_w()\n$_[0]->[6]\n→ 0..6, Sunday=0"]
C -->|"%D"| G["format_D()\nformat_m . '/' . format_d . '/' . format_y\n→ MM/DD/YY"]
C -->|"unknown"| H["return bare letter\n(fallback)"]
Reviews (1): Last reviewed commit: "feat: add %F (ISO 8601 date) and %u (Mon..." | Re-trigger Greptile
Rebase with requested adjustmentsBranch StatsActions performed
CI statusCI will be checked asynchronously. Automated by Kōan |
e798c18 to
b451703
Compare
| sudo: false | ||
| global: false | ||
| cpanfile: ".github/cpanfile" | ||
| version: "0.997016" |
There was a problem hiding this comment.
do not bump/pin the version for cpm let's use install-with-cpm@v2 instead
|
@Koan-Bot rebase |
Add two commonly-used POSIX strftime format specifiers that were missing: - %F: ISO 8601 date format (YYYY-MM-DD), equivalent to %Y-%m-%d - %u: day of the week as decimal (1=Monday, 7=Sunday) Also fix %e documentation range from 1..32 to 1..31. 15 new test cases covering all language sections plus a Sunday boundary test to verify %u correctly returns 7 (not 0) for Sundays.
- Removed pinned `version: "0.997016"` for cpm and upgraded `install-with-cpm@v1` to `install-with-cpm@v2` per reviewer request to not bump/pin the cpm version and use v2 of the action instead.
Rebase with requested adjustmentsBranch Changes applied
StatsActions performed
CI statusCI will be checked asynchronously. Automated by Kōan |
54afe00 to
797365d
Compare
What
Add two missing POSIX strftime format specifiers:
%F(ISO 8601 date) and%u(Monday-based weekday number).Why
%Fand%uare defined in POSIX.1-2001 and widely expected by users coming from C's strftime or GNU coreutilsdate. Currently,time2str("%F", time)silently returns the literal "F" instead of a date — surprising behavior for a standard code.How
format_F: composite format returning%Y-%m-%d(same pattern as existingformat_D,format_T)format_u: returns$_[0]->[6] || 7— maps Sunday from Perl's 0 to POSIX's 7%edocumentation range from1..32to1..31Testing
15 new test cases in
t/format.t(292 → 307):%Fand%utested across all 6 language sections (English, German, French, Italian, Bulgarian, Portuguese)%ureturns 7 and%wreturns 0