benilla-re systems structs docs

_Strftime

function · crt · primitive

Address
0x4134fe · 250 bytes, up to 0x4135f7
Signature
uint32_t __cdecl (char *out, uint32_t max, const char *format, const tm *fields, const char **names)
Meaning
Formats tm fields by a strftime format into max bytes; 0 when no room is left for the NUL
Confidence
verified, proof one
Finding
crt/time#the-strftime-format-loop
Test
crt::crt_strftime_difftest, crt::crt_strftime_patterns_difftest

Finding: The strftime format loop in crt: calendar time

strftime(out, max, format, tm) calls _Strftime with no time record, which takes __lc_time_curr, the C locale's record. It copies each byte of the format that is not % while room is left. A % clears the # mark, takes a # after it as the mark, and expands the next byte, whatever it is: a format that ends in % expands its NUL, which writes nothing, and reads on past it. The loop ends when the room or the format runs out; with room left it writes a NUL and answers the bytes before it, else it answers 0 with no NUL written.

The derivation is in the doc.

Callers 1

Callees 3

Calls and jumps by a bare address, from tables/calls.tsv.