diff options
author | Joerg Wunsch <joerg@FreeBSD.org> | 1995-03-01 23:08:40 +0000 |
---|---|---|
committer | Joerg Wunsch <joerg@FreeBSD.org> | 1995-03-01 23:08:40 +0000 |
commit | be7f0d04fed168c8a3156a9bcf06df3e90f38083 (patch) | |
tree | 8db609b5164ee926b5ca0ed49c6d1b60091a855c /lib/libc/stdtime/strftime.c | |
parent | c30c84ed1f78c6793e7e27d59007186752c7727d (diff) |
Notes
Diffstat (limited to 'lib/libc/stdtime/strftime.c')
-rw-r--r-- | lib/libc/stdtime/strftime.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/lib/libc/stdtime/strftime.c b/lib/libc/stdtime/strftime.c index 821bc7957467..1c50d65d4a68 100644 --- a/lib/libc/stdtime/strftime.c +++ b/lib/libc/stdtime/strftime.c @@ -55,6 +55,7 @@ static const char Bfmt[][10] = { static char *_add P((const char *, char *, const char *)); static char *_conv P((int, const char *, char *, const char *)); static char *_fmt P((const char *, const struct tm *, char *, const char *)); +static char *_secs P((const struct tm *, char *, const char *)); size_t strftime P((char *, size_t, const char *, const struct tm *)); @@ -232,6 +233,9 @@ label: case 'S': pt = _conv(t->tm_sec, "%02d", pt, ptlim); continue; + case 's': + pt = _secs(t, pt, ptlim); + continue; case 'T': case 'X': pt = _fmt("%H:%M:%S", t, pt, ptlim); @@ -382,6 +386,24 @@ _conv(n, format, pt, ptlim) } static char * +_secs(t, pt, ptlim) + const struct tm *t; + char *pt; + const char *ptlim; +{ + static char buf[INT_STRLEN_MAXIMUM(int) + 1]; + register time_t s; + register char *p; + struct tm tmp; + + /* Make a copy, mktime(3) modifies the tm struct. */ + tmp = *t; + s = mktime(&tmp); + (void) sprintf(buf, "%d", s); + return(_add(buf, pt, ptlim)); +} + +static char * _add(str, pt, ptlim) const char *str; char *pt; |