summaryrefslogtreecommitdiff
path: root/src/print.c
diff options
context:
space:
mode:
authorChristos Zoulas <christos@zoulas.com>2015-01-09 19:28:32 +0000
committerChristos Zoulas <christos@zoulas.com>2015-01-09 19:28:32 +0000
commit9b1657309055f6463f372f244683ac3a2f83d932 (patch)
tree5bfe6b1bb2fffcd87b2a1b5553d7649065ca81d1 /src/print.c
parent2091732d23c52d7e58c073cae832b2039486e04d (diff)
downloadfile-git-9b1657309055f6463f372f244683ac3a2f83d932.tar.gz
- stop doing time gymnastics for daylight savings.
- use the _r functions for struct tm retrieval
Diffstat (limited to 'src/print.c')
-rw-r--r--src/print.c31
1 files changed, 7 insertions, 24 deletions
diff --git a/src/print.c b/src/print.c
index 501236f6..25d893a5 100644
--- a/src/print.c
+++ b/src/print.c
@@ -32,7 +32,7 @@
#include "file.h"
#ifndef lint
-FILE_RCSID("@(#)$File: print.c,v 1.77 2015/01/02 21:29:39 christos Exp $")
+FILE_RCSID("@(#)$File: print.c,v 1.78 2015/01/06 02:04:10 christos Exp $")
#endif /* lint */
#include <string.h>
@@ -233,7 +233,7 @@ file_fmttime(uint64_t v, int flags, char *buf)
{
char *pp;
time_t t;
- struct tm *tm;
+ struct tm *tm, tmz;
if (flags & FILE_T_WINDOWS) {
struct timespec ts;
@@ -246,30 +246,13 @@ file_fmttime(uint64_t v, int flags, char *buf)
}
if (flags & FILE_T_LOCAL) {
- pp = ctime_r(&t, buf);
+ tm = localtime_r(&t, &tmz);
} else {
-#ifndef HAVE_DAYLIGHT
- private int daylight = 0;
-#ifdef HAVE_TM_ISDST
- private time_t now = (time_t)0;
-
- if (now == (time_t)0) {
- struct tm *tm1;
- (void)time(&now);
- tm1 = localtime(&now);
- if (tm1 == NULL)
- goto out;
- daylight = tm1->tm_isdst;
- }
-#endif /* HAVE_TM_ISDST */
-#endif /* HAVE_DAYLIGHT */
- if (daylight)
- t += 3600;
- tm = gmtime(&t);
- if (tm == NULL)
- goto out;
- pp = asctime_r(tm, buf);
+ tm = gmtime_r(&t, &tmz);
}
+ if (tm == NULL)
+ goto out;
+ pp = asctime_r(tm, buf);
if (pp == NULL)
goto out;