Skip to content

[Repo Assist] improve: extend l_strftime with 15 new POSIX format specifiers#158

Draft
github-actions[bot] wants to merge 1 commit intomainfrom
repo-assist/improve-strftime-2026-04-26-a74b8b9ab62de57b
Draft

[Repo Assist] improve: extend l_strftime with 15 new POSIX format specifiers#158
github-actions[bot] wants to merge 1 commit intomainfrom
repo-assist/improve-strftime-2026-04-26-a74b8b9ab62de57b

Conversation

@github-actions
Copy link
Copy Markdown
Contributor

🤖 This PR was created by Repo Assist, an automated AI assistant.

Summary

Extends l_strftime with 15 additional POSIX format specifiers, bringing the total from 8 to 23 supported specifiers.

Motivation

The existing implementation only handled %Y, %m, %d, %H, %M, %S, %a, %b, and %%. Many common use cases require additional specifiers — e.g., %F for ISO 8601 dates, %T for time, %j for day-of-year, %A/%B for full names, and %I/%p for 12-hour clock output.

New specifiers

Spec Meaning Example
%y 2-digit year 26
%e space-padded day 5
%A full weekday name Thursday
%B full month name September
%I 12-hour clock (01-12) 01
%p AM/PM AM
%j day of year (001-366) 252
%u weekday 1=Mon..7=Sun 4
%w weekday 0=Sun..6=Sat 4
%F ISO date (%Y-%m-%d) 2001-09-09
%T time (%H:%M:%S) 01:46:40
%R time (%H:%M) 01:46
%D US date (%m/%d/%y) 09/09/01
%n newline \n
%t tab \t

Implementation notes

  • The local tmp[8] buffer is widened to tmp[32] to accommodate compound specifiers (%F = 10 chars, %T/%D = 8 chars).
  • %j (day-of-year) uses a static month_yday[] lookup and a leap-year check.
  • %A and %B use l_strlen() for variable-length names.
  • No new dependencies; all arithmetic is integer-only.

Trade-offs

Unknown %x specifiers fall through to the default case and emit %x literally — consistent with existing behaviour.

Test Status

✅ 32 new assertions added to the l_gmtime / l_strftime section of tests/test_utils.c. All pass on Linux with gcc -Wall -Wextra -Wpedantic -ffreestanding -nostdlib -fno-builtin.

Generated by 🌈 Repo Assist at {run-started}. Learn more.

To install this agentic workflow, run

gh aw add githubnext/agentics/workflows/repo-assist.md@1f672aef974f4246124860fc532f82fe8a93a57e

Add %y, %e, %A, %B, %I, %p, %j, %u, %w, %F, %T, %R, %D, %n, %t to
l_strftime, covering the most commonly needed POSIX strftime specifiers.

Previously only 8 specifiers were supported; this brings the total to 23.
The tmp buffer is widened from 8 to 32 bytes to accommodate compound
specifiers (%F, %T, %D) that produce up to 10 characters at once.

Specifiers added:
  %y  two-digit year (00-99)
  %e  day of month, space-padded (" 1".."31")
  %A  full weekday name (Sunday..Saturday)
  %B  full month name (January..December)
  %I  12-hour clock (01-12)
  %p  AM/PM
  %j  day of year, zero-padded (001-366)
  %u  weekday 1=Monday..7=Sunday (ISO 8601)
  %w  weekday 0=Sunday..6=Saturday
  %F  ISO 8601 date (%Y-%m-%d)
  %T  time (%H:%M:%S)
  %R  time without seconds (%H:%M)
  %D  US date (%m/%d/%y)
  %n  newline
  %t  tab

Tests: 32 new assertions added to the l_gmtime/l_strftime section of
test_utils.c; all pass on Linux gcc -Wall -Wextra -Wpedantic -ffreestanding.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants