Function: f--get-time
f--get-time is a byte-compiled function defined in f.el.
Signature
(f--get-time PATH TIMESTAMP-P FN)
Documentation
Helper function, get time-related information for PATH.
Helper for f-change-time, f-modification-time,
f-access-time. It is meant to be called internally, avoid
calling it manually unless you have to.
If TIMESTAMP-P is non-nil, return the date requested as a
timestamp. If the value is 'seconds, return the timestamp as
a timestamp with a one-second precision. Otherwise, the
timestamp is returned in a (TICKS . HZ) format, see
current-time if using Emacs 29 or newer.
Otherwise, if TIMESTAMP-P is nil, return the default style of
current-time.
FN is the function specified by the caller function to retrieve the correct data from PATH.
Source Code
;; Defined in ~/.emacs.d/elpa/f-20241003.1131/f.el
(defun f--get-time (path timestamp-p fn)
"Helper function, get time-related information for PATH.
Helper for `f-change-time', `f-modification-time',
`f-access-time'. It is meant to be called internally, avoid
calling it manually unless you have to.
If TIMESTAMP-P is non-nil, return the date requested as a
timestamp. If the value is \\='seconds, return the timestamp as
a timestamp with a one-second precision. Otherwise, the
timestamp is returned in a (TICKS . HZ) format, see
`current-time' if using Emacs 29 or newer.
Otherwise, if TIMESTAMP-P is nil, return the default style of
`current-time'.
FN is the function specified by the caller function to retrieve
the correct data from PATH."
(let* ((current-time-list (not timestamp-p))
(date (apply fn (list (file-attributes path))))
(emacs29-or-newer-p (version<= "29" emacs-version)))
(cond
((and (eq timestamp-p 'seconds) emacs29-or-newer-p)
(/ (car date) (cdr date)))
((or (and (not (eq timestamp-p 'seconds)) emacs29-or-newer-p)
(and (not timestamp-p) (not emacs29-or-newer-p)))
date)
((and (eq timestamp-p 'seconds) (not emacs29-or-newer-p))
(+ (* (nth 0 date) (expt 2 16))
(nth 1 date)))
((and timestamp-p (not emacs29-or-newer-p))
`(,(+ (* (nth 0 date) (expt 2 16) 1000)
(* (nth 1 date) 1000)
(nth 3 date))
. 1000)))))