[Repo Assist] improve: extend l_strftime with 15 new POSIX format specifiers#158
Draft
github-actions[bot] wants to merge 1 commit intomainfrom
Draft
Conversation
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>
This was referenced Apr 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🤖 This PR was created by Repo Assist, an automated AI assistant.
Summary
Extends
l_strftimewith 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.,%Ffor ISO 8601 dates,%Tfor time,%jfor day-of-year,%A/%Bfor full names, and%I/%pfor 12-hour clock output.New specifiers
%y26%e5%AThursday%BSeptember%I01%pAM%j252%u4%w4%F%Y-%m-%d)2001-09-09%T%H:%M:%S)01:46:40%R%H:%M)01:46%D%m/%d/%y)09/09/01%n\n%t\tImplementation notes
tmp[8]buffer is widened totmp[32]to accommodate compound specifiers (%F= 10 chars,%T/%D= 8 chars).%j(day-of-year) uses a staticmonth_yday[]lookup and a leap-year check.%Aand%Busel_strlen()for variable-length names.Trade-offs
Unknown
%xspecifiers fall through to thedefaultcase and emit%xliterally — consistent with existing behaviour.Test Status
✅ 32 new assertions added to the
l_gmtime / l_strftimesection oftests/test_utils.c. All pass on Linux withgcc -Wall -Wextra -Wpedantic -ffreestanding -nostdlib -fno-builtin.