From e7e73fb4b2070c09f03c59f567531501762f9eeb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C5=8Dan?= Date: Fri, 13 Mar 2026 10:43:37 -0600 Subject: [PATCH] fix: add French day ordinal suffix in format_o MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit French format_o was returning bare day numbers while all other language modules include ordinal suffixes. Fixed format_o to use @Dsuf and corrected @Dsuf array indexing (was off-by-one: index 0 should be unused placeholder since days are 1-31). Results: "1er", "2e", "3e", ..., "31e" — following French convention. Closes #22 Co-Authored-By: Claude Opus 4.6 --- lib/Date/Language/French.pm | 4 ++-- t/format.t | 45 ++++++++++++++++++++++++++++++++++++- 2 files changed, 46 insertions(+), 3 deletions(-) diff --git a/lib/Date/Language/French.pm b/lib/Date/Language/French.pm index 49ca604..e1e44c4 100644 --- a/lib/Date/Language/French.pm +++ b/lib/Date/Language/French.pm @@ -22,7 +22,7 @@ our @MoYs = map { substr($_,0,3) } @MoY; $MoYs[6] = 'jul'; our @AMPM = qw(AM PM); -our @Dsuf = ((qw(er e e e e e e e e e)) x 3, 'er'); +our @Dsuf = ('e', 'er', ('e') x 30); our ( %MoY, %DoW ); Date::Language::_build_lookups(); @@ -35,6 +35,6 @@ sub format_b { $MoYs[$_[0]->[4]] } sub format_B { $MoY[$_[0]->[4]] } sub format_h { $MoYs[$_[0]->[4]] } sub format_p { $_[0]->[2] >= 12 ? $AMPM[1] : $AMPM[0] } -sub format_o { $_[0]->[3] } +sub format_o { sprintf("%2d%s",$_[0]->[3],$Dsuf[$_[0]->[3]]) } 1; diff --git a/t/format.t b/t/format.t index f6cbf58..152d114 100644 --- a/t/format.t +++ b/t/format.t @@ -1,4 +1,4 @@ -use Test::More tests => 202; +use Test::More tests => 242; use Date::Format qw(ctime time2str); use Date::Language; use utf8; @@ -125,6 +125,49 @@ German %Oq III %OY MCMXCIX %Oy XCIX +French +%y 99 +%Y 1999 +%% % +%a mar +%A mardi +%b sep +%B septembre +%c 09/07/99 13:02:42 +%C mar sep 7 13:02:42 GMT 1999 +%d 07 +%e 7 +%D 09/07/99 +%h sep +%H 13 +%I 01 +%j 250 +%k 13 +%l 1 +%L 9 +%m 09 +%M 02 +%o 7e +%p PM +%q 3 +%r 01:02:42 PM +%R 13:02 +%s 936709362 +%S 42 +%T 13:02:42 +%U 36 +%w 2 +%W 36 +%x 09/07/99 +%X 13:02:42 +%y 99 +%Y 1999 +%Z GMT +%z +0000 +915192000 # Fri Jan 1 12:00:00 1999 GMT +%o 1er +%A vendredi +936709362 # Tue Sep 7 11:22:42 1999 GMT Italian %y 99 %Y 1999