You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
date: strftime O modifier leaks as literal in C locale #11656
date leaks the strftime O modifier as literal text (e.g. %Om → %om) while GNU strips it in C locale. The O modifier requests "alternative numeric symbols" and is a no-op under LC_ALL=C.
hi @sylvestre, I found the problem, seems in coreutils/src/uu/date/src/format_modifiers.rs:82 the regex %([_0^#+-]*)(\d*)(:*[a-zA-Z]) is missing O, when I adjust to %([_O0^#+-]*)(\d*)(:*[a-zA-Z]), it prints
It's unfortunately more complex and showing the modifier as literal is sometimes the expected behavior. From the documentation:
An optional modifier can follow the optional flag and width specification. The modifiers are:
‘E’
Use the locale’s alternate representation for date and time. This modifier applies to the ‘%c’, ‘%C’, ‘%x’, ‘%X’, ‘%y’ and ‘%Y’ conversion specifiers. In a Japanese locale, for example, ‘%Ex’ might yield a date format based on the Japanese Emperors’ reigns.
‘O’
Use the locale’s alternate numeric symbols for numbers. This modifier applies only to numeric conversion specifiers.
If the format supports the modifier but no alternate representation is available, it is ignored.
And how it is currently implemented with GNU date.
For the O modifier:
$ for param in $(<sequences.txt); do LC_ALL=C TZ=UTC date -d "2024-06-15" "+%O$param"; done
%O%
%Oa
%OA
Jun
June
%Oc
20
15
%OD
15
%OF
24
2024
Jun
00
12
167
0
12
06
00
000000000
AM
am
2
12:00:00 AM
00:00
1718409600
00
00:00:00
6
23
24
6
24
%Ox
%OX
24
2024
+0000
+00:00
+00:00:00
+00
UTC
And for the E modifier:
$ for param in $(<sequences.txt); do LC_ALL=C TZ=UTC date -d "2024-06-15" "+%E$param"; done
%E%
%Ea
%EA
%Eb
%EB
Sat Jun 15 00:00:00 2024
20
%Ed
%ED
%Ee
%EF
%Eg
%EG
%Eh
%EH
%EI
%Ej
%Ek
%El
%Em
%EM
%EN
AM
am
2
12:00:00 AM
00:00
1718409600
%ES
00:00:00
6
%EU
%EV
%Ew
%EW
06/15/24
00:00:00
24
2024
+0000
+00:00
+00:00:00
+00
UTC
hi @cakebaker, thanks for clarification I suppose capturing O and E modifiers in the regex is correct? Previously, without including them in the pattern, the parser essentially ignored them regardless of which specifier followed. However, the problem now lies in the parsing logic: it must distinguish which specific combinations of O or E modifiers and conversion specifiers should result in a formatted output versus those that should be ignored.
for example, for modifier O, %OA, which is locale’s alternate representation for full weekday name, variable length, which is not applicable (the output is a string). So, for all not applicable cases like:
%O%
%Oa
%OA
%Oc
%OD
%OF
%Ox
%OX
They should be ignored.
Do we have to pre-define those cases, because from the docs:
O: This modifier applies only to numeric conversion specifiers.
Similar applies to modifier E but with more cases to be ignored.
update:
Jiff's strtime is not supporting E and O modifiers.
Activity
tobyw21 commentedon Apr 8, 2026
hi @sylvestre, I found the problem, seems in
coreutils/src/uu/date/src/format_modifiers.rs:82the regex%([_0^#+-]*)(\d*)(:*[a-zA-Z])is missingO, when I adjust to%([_O0^#+-]*)(\d*)(:*[a-zA-Z]), it printssimilar applies to
Emodifier.can I try to patch it?
sylvestre commentedon Apr 8, 2026
sure
cakebaker commentedon Apr 9, 2026
It's unfortunately more complex and showing the modifier as literal is sometimes the expected behavior. From the documentation:
And how it is currently implemented with GNU
date.For the
Omodifier:And for the
Emodifier:tobyw21 commentedon Apr 9, 2026
hi @cakebaker, thanks for clarification I suppose capturing
OandEmodifiers in the regex is correct? Previously, without including them in the pattern, the parser essentially ignored them regardless of which specifier followed. However, the problem now lies in the parsing logic: it must distinguish which specific combinations ofOorEmodifiers and conversion specifiers should result in a formatted output versus those that should be ignored.for example, for modifier
O,%OA, which is locale’s alternate representation for full weekday name, variable length, which is not applicable (the output is a string). So, for all not applicable cases like:They should be ignored.
Do we have to pre-define those cases, because from the docs:
Similar applies to modifier
Ebut with more cases to be ignored.update:
Jiff's strtime is not supporting
EandOmodifiers.