diff options
author | obrien <obrien@FreeBSD.org> | 2012-04-19 03:20:13 +0000 |
---|---|---|
committer | obrien <obrien@FreeBSD.org> | 2012-04-19 03:20:13 +0000 |
commit | 248502d7f08de3125e3e3cc808446294565ba5df (patch) | |
tree | c7640efe490a887a5460d7a88d62aca990489d21 /contrib/file/cdf_time.c | |
parent | 86e3fa59a2a400ec95b0c84576fb00815631d92f (diff) | |
parent | 15f98df7891f1853090ecb6c4a9cc734e671ef6b (diff) | |
download | FreeBSD-src-248502d7f08de3125e3e3cc808446294565ba5df.zip FreeBSD-src-248502d7f08de3125e3e3cc808446294565ba5df.tar.gz |
Update file(1) to version 5.11.
Diffstat (limited to 'contrib/file/cdf_time.c')
-rw-r--r-- | contrib/file/cdf_time.c | 33 |
1 files changed, 24 insertions, 9 deletions
diff --git a/contrib/file/cdf_time.c b/contrib/file/cdf_time.c index 932253b..5061b46 100644 --- a/contrib/file/cdf_time.c +++ b/contrib/file/cdf_time.c @@ -27,7 +27,7 @@ #include "file.h" #ifndef lint -FILE_RCSID("@(#)$File: cdf_time.c,v 1.6 2009/03/10 11:44:29 christos Exp $") +FILE_RCSID("@(#)$File: cdf_time.c,v 1.11 2011/12/13 13:48:41 christos Exp $") #endif #include <time.h> @@ -108,22 +108,22 @@ cdf_timestamp_to_timespec(struct timespec *ts, cdf_timestamp_t t) ts->tv_nsec = (t % CDF_TIME_PREC) * 100; t /= CDF_TIME_PREC; - tm.tm_sec = t % 60; + tm.tm_sec = (int)(t % 60); t /= 60; - tm.tm_min = t % 60; + tm.tm_min = (int)(t % 60); t /= 60; - tm.tm_hour = t % 24; + tm.tm_hour = (int)(t % 24); t /= 24; // XXX: Approx - tm.tm_year = CDF_BASE_YEAR + (t / 365); + tm.tm_year = (int)(CDF_BASE_YEAR + (t / 365)); rdays = cdf_getdays(tm.tm_year); - t -= rdays; - tm.tm_mday = cdf_getday(tm.tm_year, t); - tm.tm_mon = cdf_getmonth(tm.tm_year, t); + t -= rdays - 1; + tm.tm_mday = cdf_getday(tm.tm_year, (int)t); + tm.tm_mon = cdf_getmonth(tm.tm_year, (int)t); tm.tm_wday = 0; tm.tm_yday = 0; tm.tm_isdst = 0; @@ -143,10 +143,13 @@ cdf_timestamp_to_timespec(struct timespec *ts, cdf_timestamp_t t) } int +/*ARGSUSED*/ cdf_timespec_to_timestamp(cdf_timestamp_t *t, const struct timespec *ts) { +#ifndef __lint__ (void)&t; (void)&ts; +#endif #ifdef notyet struct tm tm; if (gmtime_r(&ts->ts_sec, &tm) == NULL) { @@ -162,6 +165,18 @@ cdf_timespec_to_timestamp(cdf_timestamp_t *t, const struct timespec *ts) return 0; } +char * +cdf_ctime(const time_t *sec) +{ + static char ctbuf[26]; + char *ptr = ctime(sec); + if (ptr != NULL) + return ptr; + (void)snprintf(ctbuf, sizeof(ctbuf), "*Bad* 0x%16.16llx\n", + (long long)*sec); + return ctbuf; +} + #ifdef TEST int @@ -173,7 +188,7 @@ main(int argc, char *argv[]) char *p, *q; cdf_timestamp_to_timespec(&ts, tst); - p = ctime(&ts.tv_sec); + p = cdf_ctime(&ts.tv_sec); if ((q = strchr(p, '\n')) != NULL) *q = '\0'; if (strcmp(ref, p) != 0) |