help-emacs-windows
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [h-e-w] Odd dired date format


From: Dr Francis J. Wright
Subject: Re: [h-e-w] Odd dired date format
Date: Mon, 9 Sep 2002 12:59:19 +0100

From: "Geert Ribbers" <address@hidden>
To: <address@hidden>
Cc: <address@hidden>; <address@hidden>
Sent: Friday, September 06, 2002 1:05 PM
Subject: Re: [h-e-w] Odd dired date format


> The function that arranges this is copied below.
> There is no way to influence this behavior (other than overwriting the
> function in your .emacs), it's hardcoded.

I was going to respond with a similar comment myself.

> It would probably be a good idea if the authors would introduce a
> custom-variable for it (authors copied).
>
> Regards, Geert Ribbers
> :
> (defun ls-lisp-format-time (file-attr time-index now)
>   "Format time for file with attributes FILE-ATTR according to TIME-INDEX.
> Use the same method as ls to decide whether to show time-of-day or year,
> depending on distance between file date and NOW.
> All ls time options, namely c, t and u, are handled."
>   (let* ((time (nth (or time-index 5) file-attr)) ; default is last
modtime
> (diff16 (- (car time) (car now)))
> (diff (+ (ash diff16 16) (- (car (cdr time)) (car (cdr now)))))
> (past-cutoff (- (* 6 30 24 60 60))) ; 6 30-day months
> (future-cutoff (* 60 60))) ; 1 hour
>     (condition-case nil
> (format-time-string
> (if (and
>       (<= past-cutoff diff) (<= diff future-cutoff)
>       ;; Sanity check in case `diff' computation overflowed.
>       (<= (1- (ash past-cutoff -16)) diff16)
>       (<= diff16 (1+ (ash future-cutoff -16))))
>      "%b %e %H:%M"
>    "%b %e  %Y")
> time)
>       (error "Unk  0  0000"))))

I don't think I changed the above function, at least not significantly.
However, looking at it again it does seem a bit daft to recompute those
constants every time the function is called, which is once for ever file
listed.  Pre-computing them would fit in nicely with making them
customizable.  I'll see about making that change to my version of ls-lisp
and I'll let the list know when I have done it.

Francis





reply via email to

[Prev in Thread] Current Thread [Next in Thread]