Function: time-convert
time-convert is a function defined in timefns.c.
Signature
(time-convert TIME FORM)
Documentation
Convert TIME value to a Lisp timestamp of the given FORM.
Truncate the returned value toward minus infinity.
If FORM is a positive integer, return a pair of integers (TICKS . FORM), where TICKS is the number of clock ticks and FORM is the clock frequency in ticks per second.
If FORM is t, return (TICKS . PHZ), where PHZ is a suitable clock frequency in ticks per second.
If FORM is integer, return an integer count of seconds.
If FORM is list, return an integer list (HIGH LOW USEC PSEC), where
HIGH has the most significant bits of the seconds, LOW has the least
significant 16 bits, and USEC and PSEC are the microsecond and
picosecond counts.
If FORM is nil, the behavior depends on current-time-list,
but new code should not rely on it.
Probably introduced at or before Emacs version 27.1.
Aliases
cperl--time-convert
timeclock-seconds-to-time (obsolete since 26.1)
Source Code
// Defined in /usr/src/emacs/src/timefns.c
{
/* FIXME: Any reason why we don't offer a `float` output format option as
well, since we accept it as input? */
struct ticks_hz t = decode_lisp_time (time, CFORM_TICKS_HZ).th;
form = (!NILP (form) ? maybe_remove_pos_from_symbol (form)
: current_time_list ? Qlist : Qt);
if (BASE_EQ (form, Qlist))
return ticks_hz_list4 (t.ticks, t.hz);
if (BASE_EQ (form, Qinteger))
return FASTER_TIMEFNS && INTEGERP (time) ? time : ticks_hz_seconds (t);
if (BASE_EQ (form, Qt))
form = t.hz;
if (FASTER_TIMEFNS && CONSP (time) && BASE_EQ (form, XCDR (time)))
return time;
return Fcons (ticks_hz_hz_ticks (t, form), form);
}