diff options
author | roberto <roberto@FreeBSD.org> | 2004-07-20 15:01:56 +0000 |
---|---|---|
committer | roberto <roberto@FreeBSD.org> | 2004-07-20 15:01:56 +0000 |
commit | 118e757284cbb8fc4f43a713e892b41504b50a5f (patch) | |
tree | 528d12dda44ebdc3ffcc38050f159ac553a69c17 /contrib/ntp/libntp/humandate.c | |
parent | a85d9ae25e8e8696677bc30feb6eaf7fc150e529 (diff) | |
download | FreeBSD-src-118e757284cbb8fc4f43a713e892b41504b50a5f.zip FreeBSD-src-118e757284cbb8fc4f43a713e892b41504b50a5f.tar.gz |
Virgin import of ntpd 4.2.0
Diffstat (limited to 'contrib/ntp/libntp/humandate.c')
-rw-r--r-- | contrib/ntp/libntp/humandate.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/contrib/ntp/libntp/humandate.c b/contrib/ntp/libntp/humandate.c index 7995633..52f5af1 100644 --- a/contrib/ntp/libntp/humandate.c +++ b/contrib/ntp/libntp/humandate.c @@ -24,11 +24,14 @@ humandate( struct tm *tm; time_t sec; - LIB_GETBUF(bp); - sec = ntptime - JAN_1970; tm = localtime(&sec); + if (!tm) + return "--- --- -- ---- --:--:--"; + + LIB_GETBUF(bp); + (void) sprintf(bp, "%s, %s %2d %4d %2d:%02d:%02d", days[tm->tm_wday], months[tm->tm_mon], tm->tm_mday, 1900+tm->tm_year, tm->tm_hour, tm->tm_min, tm->tm_sec); @@ -47,6 +50,9 @@ humanlogtime(void) time_t cursec = time((time_t *) 0); struct tm *tm = localtime(&cursec); + if (!tm) + return "-- --- --:--:--"; + LIB_GETBUF(bp); (void) sprintf(bp, "%2d %s %02d:%02d:%02d", |