Skip to content

[bug] printf '%(fmt)T': %l/%k/%u strftime specs unimplemented (literal passthrough) AND the time is formatted in UTC instead of localtime (TZ ignored) #326

Closed

Description

@caomengxuan666

Found by ecosweep3 lane (pure-bash-bible corpus, section 076 'Get the current date using strftime'; carrier release build of 6106961).

Reproducer A — missing format specs (target/probe-out/p8.sh)

printf '%(%a %d %b - %l:%M %p)T\n' -1
printf '%(%l|%e|%k|%u|%V|%G)T\n' -1
  • GNU: Tue 29 Sep - 4:21 PM / 4|29|16|2|40|2026
  • rubash: Tue 29 Sep - %l:21 AM / %l|29|%k|%u|%V|%G

Unsupported (printed literally): %l (12-hour space-padded), %k (24-hour space-padded), %u (ISO day of week). Working: %a %d %b %M %p %e %V %G %H.

Reproducer B — UTC instead of localtime (target/probe-out/p12.sh)

printf '%(%H:%M)T\n' -1
printf '%(%Z)T\n' -1
  • GNU (WSL, TZ=CST-8): 16:22 / CST
  • rubash (same wall clock, Windows host is CST): 08:22 / UTC

GNU anchor

builtins/printf.def:633 (+637) tm = localtime (&secs); — bash %(fmt)T formats with localtime; the format then goes to system strftime (glibc), which owns %l/%k/%u. rubash must call the localtime conversion (Windows: localtime_s / TZ env) and extend its strftime subset table with %l/%k/%u.

Impact

pbb date section prints %l literally and the wrong half of the day; any prompt/theme script formatting time via printf %()T is off by the timezone and loses padded-hour formats.

Activity

  1. added
    bug
    gnu-baseline
    on Sep 29, 2026
  2. added a commit that references this issue on Sep 29, 2026
  3. caomengxuan666 commented on Sep 29, 2026

    @caomengxuan666
    MemberAuthor

    Fixed by wt14/pbbfix (a4107ce, master): the strftime subset lacked %l/%k/%u (and the likewise-literal %V/%G) and hardcoded UTC when TZ was unset. All new specs + ISO-week boundaries + POSIX TZ forms (CST-8/EST5EDT both seasons/UTC/empty=Universal) + the system-timezone fallback (GetTimeZoneInformation) verified line-by-line byte-identical; pbb 076 date segment matches. Anchors: printf.def:633 localtime + glibc strftime. Platform residuals: %Z text is the Windows localized name; Olson TZ names without tzdata stay UTC.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    buggnu-baseline

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions