static int format_needs_type;
+/* strftime formats for non-recent and recent files, respectively, in
+ -l output. */
+
+static char const *long_time_format[2];
+
/* The exit status to use if we don't get any fatal errors. */
static int exit_status;
sort_type = sort_time;
}
+ if (format == long_format)
+ {
+ if (full_time)
+ long_time_format[0] = long_time_format[1] = _("%a %b %d %H:%M:%S %Y");
+ else
+ {
+ long_time_format[0] = _("%b %e %Y");
+ long_time_format[1] = _("%b %e %H:%M");
+ }
+ }
+
return optind;
}
char *p;
time_t when;
struct tm *when_local;
- const char *fmt;
char *user_name;
#if HAVE_ST_DM_MODE
break;
}
- if (full_time)
- {
- fmt = _("%a %b %d %H:%M:%S %Y");
- }
- else
- {
- if (current_time > when + 6L * 30L * 24L * 60L * 60L /* Old. */
- || current_time < when - 60L * 60L) /* In the future. */
- {
- /* The file is fairly old or in the future.
- POSIX says the cutoff is 6 months old;
- approximate this by 6*30 days.
- Allow a 1 hour slop factor for what is considered "the future",
- to allow for NFS server/client clock disagreement.
- Show the year instead of the time of day. */
- fmt = _("%b %e %Y");
- }
- else
- {
- fmt = _("%b %e %H:%M");
- }
- }
-
p = buf;
if (print_inode)
if ((when_local = localtime (&when)))
{
+ /* The file is recent if it is neither old nor in the future.
+ POSIX says the cutoff is 6 months old;
+ approximate this by 6*30 days.
+ Allow a 1 hour slop factor for what is considered "the future",
+ to allow for NFS server/client clock disagreement. */
+ int recent = (current_time <= when + 6L * 30L * 24L * 60L * 60L
+ && when - 60L * 60L <= current_time);
+
+ char const *fmt = long_time_format[recent];
*p = '\1';
while (! (s = strftime (p, buf + bufsize - p - 1, fmt, when_local))