* Copyright (c) 1989 The Regents of the University of California.
* Redistribution and use in source and binary forms are permitted
* provided that the above copyright notice and this paragraph are
* duplicated in all such forms and that any documentation,
* advertising materials, and other materials related to such
* distribution and use acknowledge that the software was developed
* by the University of California, Berkeley. The name of the
* University may not be used to endorse or promote products derived
* from this software without specific prior written permission.
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
#if defined(LIBC_SCCS) && !defined(lint)
static char sccsid
[] = "@(#)strftime.c 5.6 (Berkeley) %G%";
#endif /* LIBC_SCCS and not lint */
"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat",
"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday",
"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep",
"January", "February", "March", "April", "May", "June", "July",
"August", "September", "October", "November", "December",
strftime(s
, maxsize
, format
, t
)
if ((gsize
= maxsize
) < 1)
for (; *format
; ++format
) {
if (t
->tm_wday
< 0 || t
->tm_wday
> 6)
if (!_add(Afmt
[t
->tm_wday
]))
if (t
->tm_wday
< 0 || t
->tm_wday
> 6)
if (!_add(afmt
[t
->tm_wday
]))
if (t
->tm_mon
< 0 || t
->tm_mon
> 11)
if (!_add(Bfmt
[t
->tm_mon
]))
if (t
->tm_mon
< 0 || t
->tm_mon
> 11)
if (!_add(bfmt
[t
->tm_mon
]))
if (!_fmt("%a %b %e %H:%M:%S %Y", t
))
if (!_fmt("%m/%d/%y %H:%M:%S", t
))
if (!_conv(t
->tm_mday
, 2, ' '))
if (!_fmt("%m/%d/%y", t
))
if (!_conv(t
->tm_mday
, 2, '0'))
if (!_conv(t
->tm_hour
, 2, '0'))
if (!_conv(t
->tm_hour
% 12 ?
t
->tm_hour
% 12 : 12, 2, '0'))
if (!_conv(t
->tm_yday
+ 1, 3, '0'))
if (!_conv(t
->tm_hour
, 2, ' '))
if (!_conv(t
->tm_hour
% 12 ?
t
->tm_hour
% 12 : 12, 2, ' '))
if (!_conv(t
->tm_min
, 2, '0'))
if (!_conv(t
->tm_mon
+ 1, 2, '0'))
if (!_add(t
->tm_hour
>= 12 ? "PM" : "AM"))
if (!_fmt("%I:%M:%S %p", t
))
if (!_conv(t
->tm_sec
, 2, '0'))
if (!_fmt("%H:%M:%S", t
))
if (!_conv((t
->tm_yday
+ 7 - t
->tm_wday
) / 7,
if (!_conv((t
->tm_yday
+ 7 -
(t
->tm_wday
? (t
->tm_wday
- 1) : 6))
if (!_conv(t
->tm_wday
, 1, '0'))
if (!_fmt("%m/%d/%y", t
))
if (!_conv((t
->tm_year
+ TM_YEAR_BASE
)
if (!_conv(t
->tm_year
+ TM_YEAR_BASE
, 4, '0'))
if (!t
->tm_zone
|| !_add(t
->tm_zone
))
* X311J/88-090 (4.12.3.5): if conversion char is
* undefined, behavior is undefined. Print out the
* character itself as printf(3) does.
for (p
= buf
+ sizeof(buf
) - 2; n
> 0 && p
> buf
; n
/= 10, --digits
)
while (p
> buf
&& digits
-- > 0)