SCCS-vsn: lib/libc/string/strftime.c 5.3
*/
#if defined(LIBC_SCCS) && !defined(lint)
*/
#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)strftime.c 5.2 (Berkeley) %G%";
+static char sccsid[] = "@(#)strftime.c 5.3 (Berkeley) %G%";
#endif /* LIBC_SCCS and not lint */
#include <sys/types.h>
#endif /* LIBC_SCCS and not lint */
#include <sys/types.h>
register char *format;
struct tm *t;
{
register char *format;
struct tm *t;
{
for (; *format; ++format) {
if (*format == '%')
switch(*++format) {
for (; *format; ++format) {
if (*format == '%')
switch(*++format) {
+ case '\0':
+ --format;
+ break;
- if (!_add(Afmt[t->tm_mon]))
+ if (t->tm_wday < 0 || t->tm_wday > 6)
+ return(0);
+ if (!_add(Afmt[t->tm_wday]))
return(0);
continue;
case 'a':
return(0);
continue;
case 'a':
- if (!_add(afmt[t->tm_mon]))
+ if (t->tm_wday < 0 || t->tm_wday > 6)
+ return(0);
+ if (!_add(afmt[t->tm_wday]))
return(0);
continue;
case 'B':
return(0);
continue;
case 'B':
+ if (t->tm_mon < 0 || t->tm_mon > 11)
+ return(0);
if (!_add(Bfmt[t->tm_mon]))
return(0);
continue;
case 'b':
case 'h':
if (!_add(Bfmt[t->tm_mon]))
return(0);
continue;
case 'b':
case 'h':
+ if (t->tm_mon < 0 || t->tm_mon > 11)
+ return(0);
if (!_add(bfmt[t->tm_mon]))
return(0);
continue;
if (!_add(bfmt[t->tm_mon]))
return(0);
continue;
return(0);
continue;
case 'I':
return(0);
continue;
case 'I':
- if (!_conv((t->tm_hour - 1) % 12 + 1, 2))
+ if (!_conv(t->tm_hour % 12 ?
+ t->tm_hour % 12 : 12, 2))
return(0);
continue;
case 'j':
return(0);
continue;
case 'j':
return(0);
continue;
case 'p':
return(0);
continue;
case 'p':
- if (!_add(t->tm_hour >= 12 ? "AM" : "PM"))
+ if (!_add(t->tm_hour >= 12 ? "PM" : "AM"))
return(0);
continue;
case 'R':
return(0);
continue;
case 'R':
continue;
case 'W':
if (!_conv((t->tm_yday + 7 -
continue;
case 'W':
if (!_conv((t->tm_yday + 7 -
- (t->tm_wday ? t->tm_wday : 6)) / 7, 2))
+ (t->tm_wday ? (t->tm_wday - 1) : 6))
+ / 7, 2))
return(0);
continue;
case 'w':
return(0);
continue;
case 'w':
return(0);
continue;
case 'x':
return(0);
continue;
case 'x':
- if (!_fmt("%a %b %d", t))
+ if (!_fmt("%a %b %d %Y", t))
return(0);
continue;
case 'y':
return(0);
continue;
case 'y':
return(0);
continue;
case 'Z':
return(0);
continue;
case 'Z':
+ if (!t->tm_zone || !_add(t->tm_zone))
return(0);
continue;
case '%':
return(0);
continue;
case '%':