Skip to content

Commit bc56df3

Browse files
phidebianMcDutchie
authored andcommitted
printf: fix %T for date specs relative to now (re: 1a9d8ad) (#916)
The referenced commit introduced a bug: printf "%(%Y-%m-%d)T\n" "now in 10 week" printf "%(%Y-%m-%d)T\n" "in 10 weeks" produce today's date. As of this fix, they produce the date in ten weeks. src/lib/libast/tm/tmxdate.c::1456 case TM_PARTS+4: tm = tmxtm(tm, tmxtime(tm, zone), tm->tm_zone, 0); tm->tm_hour += m * 7 * 24; set |= DAY; // <======= BUG HERE goto clear_hour; The fix: since we are updating tm_hour, set HOUR, not DAY. Resolves: #915
1 parent f99e786 commit bc56df3

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ Uppercase BUG_* IDs are shell bug IDs as used by the Modernish shell library.
44

55
2026-01-28:
66

7+
- Fixed a regression, introduced with the printf fixes on 2023-05-18, that
8+
broke date specs relative to now, such as: printf '%T\n' 'in 10 weeks'
9+
710
- Fixed incorrect behaviour that occurred when IFS, PATH, SHELL,
811
FPATH, CDPATH, SECONDS, ENV, LANG, LC_ALL, LC_CTYPE, LC_MESSAGES,
912
LC_COLLATE, LC_NUMERIC, or LC_TIME were declared as a local

src/lib/libast/tm/tmxdate.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1453,7 +1453,7 @@ tmxdate(const char* s, char** e, Time_t now)
14531453
case TM_PARTS+4:
14541454
tm = tmxtm(tm, tmxtime(tm, zone), tm->tm_zone, 0);
14551455
tm->tm_hour += m * 7 * 24;
1456-
set |= DAY;
1456+
set |= HOUR;
14571457
goto clear_hour;
14581458
case TM_PARTS+5:
14591459
tm->tm_mon += m;

0 commit comments

Comments
 (0)