File tree Expand file tree Collapse file tree 2 files changed +36
-2
lines changed
Expand file tree Collapse file tree 2 files changed +36
-2
lines changed Original file line number Diff line number Diff line change @@ -487,7 +487,14 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
487487 } else {
488488 date
489489 } ;
490- match format_date_with_locale_aware_months ( & date, format_string, & config) {
490+ let skip_localization =
491+ matches ! ( settings. format, Format :: Rfc5322 | Format :: Rfc3339 ( _) ) ;
492+ match format_date_with_locale_aware_months (
493+ & date,
494+ format_string,
495+ & config,
496+ skip_localization,
497+ ) {
491498 Ok ( s) => writeln ! ( stdout, "{s}" ) . map_err ( |e| {
492499 USimpleError :: new ( 1 , translate ! ( "date-error-write" , "error" => e) )
493500 } ) ?,
@@ -631,10 +638,11 @@ fn format_date_with_locale_aware_months(
631638 date : & Zoned ,
632639 format_string : & str ,
633640 config : & Config < PosixCustom > ,
641+ skip_localization : bool ,
634642) -> Result < String , jiff:: Error > {
635643 let broken_down = BrokenDownTime :: from ( date) ;
636644
637- if !should_use_icu_locale ( ) {
645+ if !should_use_icu_locale ( ) || skip_localization {
638646 return broken_down. to_string_with_config ( config, format_string) ;
639647 }
640648
Original file line number Diff line number Diff line change @@ -86,6 +86,32 @@ fn test_date_email_multiple_aliases() {
8686 . succeeds ( ) ;
8787}
8888
89+ #[ test]
90+ #[ cfg( unix) ]
91+ fn test_date_rfc_822_uses_english ( ) {
92+ // RFC-822/RFC-2822/RFC-5322 formats should always use English day/month names
93+ // regardless of locale (per RFC specification)
94+ let scene = TestScenario :: new ( util_name ! ( ) ) ;
95+
96+ // Test with German locale - should still output "Sun" not "So"
97+ scene
98+ . ucmd ( )
99+ . env ( "LC_ALL" , "de_DE.UTF-8" )
100+ . env ( "TZ" , "UTC" )
101+ . args ( & [ "-R" , "-d" , "1997-01-19 08:17:48 +0" ] )
102+ . succeeds ( )
103+ . stdout_contains ( "Sun, 19 Jan 1997" ) ;
104+
105+ // Test with French locale - should still output "Sun" not "dim."
106+ scene
107+ . ucmd ( )
108+ . env ( "LC_ALL" , "fr_FR.UTF-8" )
109+ . env ( "TZ" , "UTC" )
110+ . args ( & [ "-R" , "-d" , "1997-01-19 08:17:48 +0" ] )
111+ . succeeds ( )
112+ . stdout_contains ( "Sun, 19 Jan 1997" ) ;
113+ }
114+
89115#[ test]
90116fn test_date_rfc_3339 ( ) {
91117 let scene = TestScenario :: new ( util_name ! ( ) ) ;
You can’t perform that action at this time.
0 commit comments