From: Tim Kientzle Date: Sun, 26 Jul 2009 21:42:30 +0000 (-0400) Subject: Refactor the date formatting slightly. X-Git-Tag: v2.8.0~503 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1ccab4064b02802dfb09f74838557f7238646b4a;p=thirdparty%2Flibarchive.git Refactor the date formatting slightly. SVN-Revision: 1280 --- diff --git a/tar/read.c b/tar/read.c index 16709a3f7..b95b0217c 100644 --- a/tar/read.c +++ b/tar/read.c @@ -416,18 +416,16 @@ list_item_verbose(struct bsdtar *bsdtar, FILE *out, struct archive_entry *entry) /* Format the time using 'ls -l' conventions. */ tim = archive_entry_mtime(entry); +#define HALF_YEAR (time_t)365 * 86400 / 2 #if defined(_WIN32) && !defined(__CYGWIN__) - /* Windows' strftime function does not support %e format. */ - if (abs(tim - now) > (365/2)*86400) - fmt = bsdtar->day_first ? "%d %b %Y" : "%b %d %Y"; - else - fmt = bsdtar->day_first ? "%d %b %H:%M" : "%b %d %H:%M"; +#define DAY_FMT "%d" /* Windows' strftime function does not support %e format. */ #else - if (abs(tim - now) > (365/2)*86400) - fmt = bsdtar->day_first ? "%e %b %Y" : "%b %e %Y"; - else - fmt = bsdtar->day_first ? "%e %b %H:%M" : "%b %e %H:%M"; +#define DAY_FMT "%e" /* Day number without leading zeros */ #endif + if (tim < now - HALF_YEAR || tim > now + HALF_YEAR) + fmt = bsdtar->day_first ? DAY_FMT " %b %Y" : "%b " DAY_FMT " %Y"; + else + fmt = bsdtar->day_first ? DAY_FMT " %b %H:%M" : "%b " DAY_FMT " %H:%M"; strftime(tmp, sizeof(tmp), fmt, localtime(&tim)); fprintf(out, " %s ", tmp); safe_fprintf(out, "%s", archive_entry_pathname(entry));