Reputation: 1891
I tried to supply strftime the modifier %k which is not in the list, and it prints 11, what does strftime do, when I supply a modifier that is not in its list ?
Upvotes: 0
Views: 74
Reputation: 16607
%k
- The hour as a decimal number, using a 24-hour clock like%H
, but padded with blank (range 0 through 23).
But this format is a GNU extension. See here listed specifiers.
And if the specifier not listed is used code will exbhit undefined behaviour.
Upvotes: 1
Reputation: 172578
From the C standard of strftime
:
6 If a conversion specifier is not one of the above, the behavior is undefined.
You can see the list of format specifiers for strftime. So what you are getting is an undefined behavior.
See the manual which says about %k
%k The hour (24-hour clock) as a decimal number (range 0 to 23); single digits are preceded by a blank. (See also %H.) (TZ)
Upvotes: 1