SCCS-vsn: lib/libc/string/strftime.3 5.7
SCCS-vsn: lib/libc/string/strftime.c 5.9
.\"
.\" %sccs.include.redist.man%
.\"
.\"
.\" %sccs.include.redist.man%
.\"
-.\" @(#)strftime.3 5.6 (Berkeley) %G%
+.\" @(#)strftime.3 5.7 (Berkeley) %G%
.\"
.TH STRFTIME 3 "%Q"
.AT 3
.\"
.TH STRFTIME 3 "%Q"
.AT 3
.B %S
is replaced by the second as a decimal number (00-60).
.TP
.B %S
is replaced by the second as a decimal number (00-60).
.TP
+.B %s
+is replaced by the number of seconds since the Epoch, UCT (see
+.IR mktime (3)).
+.TP
.B %T or %X
is equivalent to ``%H:%M:%S''.
.TP
.B %T or %X
is equivalent to ``%H:%M:%S''.
.TP
is replaced by ``%''.
.SH "SEE ALSO"
date(1), ctime(3), printf(1), printf(3)
is replaced by ``%''.
.SH "SEE ALSO"
date(1), ctime(3), printf(1), printf(3)
+.SH BUGS
+The is no conversion specification for the phase of the moon.
.SH STANDARDS
.B Strftime
conforms to ANSI X3.159-1989 (``ANSI C'').
.SH STANDARDS
.B Strftime
conforms to ANSI X3.159-1989 (``ANSI C'').
*/
#if defined(LIBC_SCCS) && !defined(lint)
*/
#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)strftime.c 5.8 (Berkeley) %G%";
+static char sccsid[] = "@(#)strftime.c 5.9 (Berkeley) %G%";
#endif /* LIBC_SCCS and not lint */
#include <sys/types.h>
#endif /* LIBC_SCCS and not lint */
#include <sys/types.h>
if (!_fmt("%m/%d/%y %H:%M:%S", t))
return(0);
continue;
if (!_fmt("%m/%d/%y %H:%M:%S", t))
return(0);
continue;
- case 'e':
- if (!_conv(t->tm_mday, 2, ' '))
- return(0);
- continue;
case 'D':
if (!_fmt("%m/%d/%y", t))
return(0);
case 'D':
if (!_fmt("%m/%d/%y", t))
return(0);
if (!_conv(t->tm_mday, 2, '0'))
return(0);
continue;
if (!_conv(t->tm_mday, 2, '0'))
return(0);
continue;
+ case 'e':
+ if (!_conv(t->tm_mday, 2, ' '))
+ return(0);
+ continue;
case 'H':
if (!_conv(t->tm_hour, 2, '0'))
return(0);
case 'H':
if (!_conv(t->tm_hour, 2, '0'))
return(0);
if (!_conv(t->tm_sec, 2, '0'))
return(0);
continue;
if (!_conv(t->tm_sec, 2, '0'))
return(0);
continue;
+ case 's':
+ if (!_secs(t))
+ return(0);
+ continue;
case 'T':
case 'X':
if (!_fmt("%H:%M:%S", t))
case 'T':
case 'X':
if (!_fmt("%H:%M:%S", t))
+static
+_secs(t)
+ struct tm *t;
+{
+ static char buf[15];
+ register time_t s;
+ register char *p;
+
+ s = mktime(t);
+ for (p = buf + sizeof(buf) - 2; s > 0 && p > buf; s /= 10)
+ *p-- = s % 10 + '0';
+ return(_add(++p));
+}
+
static
_conv(n, digits, pad)
int n, digits;
static
_conv(n, digits, pad)
int n, digits;