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 | |
parent | c30c84ed1f78c6793e7e27d59007186752c7727d (diff) |
Notes
-rw-r--r-- | lib/libc/stdtime/strftime.3 | 2 | ||||
-rw-r--r-- | lib/libc/stdtime/strftime.c | 22 |
2 files changed, 23 insertions, 1 deletions
diff --git a/lib/libc/stdtime/strftime.3 b/lib/libc/stdtime/strftime.3 index 3da35a1c4460..fd510ba7730e 100644 --- a/lib/libc/stdtime/strftime.3 +++ b/lib/libc/stdtime/strftime.3 @@ -141,7 +141,7 @@ is replaced by a tab. .It Cm \&%S is replaced by the second as a decimal number (00-60). .It Cm %s -is replaced by the number of seconds since the Epoch, UCT (see +is replaced by the number of seconds since the Epoch, UTC (see .Xr mktime 3 ) . .It Cm \&%T No or Cm \&%X is equivalent to 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; |