Function: time-convert

time-convert is a function defined in timefns.c.

Signature

(time-convert TIME &optional FORM)

Documentation

Convert TIME value to a Lisp timestamp.

With optional FORM, convert to that timestamp form. Truncate the returned value toward minus infinity.

If FORM is nil (the default), return the same form as current-time. 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. (Currently the positive integer should be at least
65536 if the returned value is expected to be given to standard functions
expecting Lisp timestamps.) 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.

Probably introduced at or before Emacs version 27.1.

Aliases

cperl--time-convert timeclock-seconds-to-time (obsolete since 26.1) seconds-to-time

Source Code

// Defined in /usr/src/emacs/src/timefns.c
{
  struct lisp_time t;
  enum timeform input_form = decode_lisp_time (time, 0, &t, 0);
  if (NILP (form))
    form = CURRENT_TIME_LIST ? Qlist : Qt;
  if (EQ (form, Qlist))
    return ticks_hz_list4 (t.ticks, t.hz);
  if (EQ (form, Qinteger))
    return FASTER_TIMEFNS && INTEGERP (time) ? time : lisp_time_seconds (t);
  if (EQ (form, Qt))
    form = t.hz;
  if (FASTER_TIMEFNS
      && input_form == TIMEFORM_TICKS_HZ && EQ (form, XCDR (time)))
    return time;
  return Fcons (lisp_time_hz_ticks (t, form), form);
}