@@ -106,3 +106,40 @@ uninitialized spinlock and invalid spinlock is left undefined. We follow the rec
106106POSIX.1-2024, where EINVAL is returned if the spinlock is invalid (here we only check for null pointers) or
107107EBUSY is returned if the spinlock is currently locked. The lock is poisoned after a successful destroy. That is,
108108subsequent operations on the lock object without any reinitialization will return EINVAL.
109+
110+ Strftime
111+ --------
112+ In the C Standard, it provides a list of modifiers, and the conversions these
113+ are valid on. It also says that a modifier on an unspecified conversion is
114+ undefined. For LLVM-libc, the conversion is treated as if the modifier isn't
115+ there.
116+
117+ If a struct tm with values out of the normal range is passed, the standard says
118+ the result is undefined. For LLVM-libc, the result may be either the normalized
119+ value (e.g. weekday % 7) or the actual, out of range value. For any numeric
120+ conversion where the result is just printing a value out of the struct
121+ (e.g. "%w" prints the day of the week), no normalization occurs ("%w" on a
122+ tm_wday of 32 prints "32"). For any numeric conversion where the value is
123+ calculated (e.g. "%u" prints the day of the week, starting on monday), the
124+ value is normalized (e.g. "%u" on a tm_wday of 32 prints "4"). For conversions
125+ that result in strings, passing an out of range value will result in "?".
126+
127+ Posix adds padding support to strftime, but says "the default padding character
128+ is unspecified." For LLVM-libc, the default padding character is ' ' (space)
129+ for all string-type conversions and '0' for integer-type conversions. Composite
130+ conversions pass the padding to the first (leftmost) conversion. In practice
131+ this is always a numeric conversion, so it pads with '0'. For the purposes of
132+ padding, composite conversions also assume the non-leading conversions have
133+ valid inputs and output their expected number of characters. For %c this means
134+ that the padding will be off if the year is outside of the range -999 to 9999.
135+
136+ The %e conversion is padded with spaces by default, but pads with 0s if the '0'
137+ flag is set.
138+
139+ Posix also adds flags and a minimum field width, but leaves unspecified what
140+ happens for most combinations of these. For LLVM-libc:
141+ An unspecified minimum field width defaults to 0.
142+ More specific flags take precedence over less specific flags (i.e. '+' takes precedence over '0')
143+ Any conversion with a minimum width is padded with the padding character until it is at least as long as the minimum width.
144+ Modifiers are applied, then the result is padded if necessary.
145+ Any composite conversion will pass along all flags to the component conversions.
0 commit comments