module_make_time (emacs_env *env, struct timespec time)
{
MODULE_FUNCTION_BEGIN (NULL);
- return lisp_to_value (env, make_lisp_time (time));
+ return lisp_to_value (env, timespec_to_lisp (time));
}
static void
/* defined in timefns.c */
extern struct timeval make_timeval (struct timespec) ATTRIBUTE_CONST;
extern Lisp_Object make_lisp_time (struct timespec);
+extern Lisp_Object timespec_to_lisp (struct timespec);
extern bool list4_to_timespec (Lisp_Object, Lisp_Object, Lisp_Object,
Lisp_Object, struct timespec *);
extern struct timespec lisp_time_argument (Lisp_Object);
make_fixnum (ns / 1000), make_fixnum (ns % 1000 * 1000));
}
else
- return Fcons (timespec_ticks (t), timespec_hz);
+ return timespec_to_lisp (t);
+}
+
+/* Return (TICKS . HZ) for time T. */
+struct Lisp_Object
+timespec_to_lisp (struct timespec t)
+{
+ return Fcons (timespec_ticks (t), timespec_hz);
}
/* Convert T to a Lisp timestamp. FORM specifies the timestamp format. */
;; New (TICKS . HZ) format.
'(123456789 . 1000000000)))
(ert-info ((format "input: %s" input))
- (should (time-equal-p (mod-test-add-nanosecond input)
- (time-add input '(0 0 0 1000)))))))
+ (let ((result (mod-test-add-nanosecond input)))
+ (should (consp result))
+ (should (integerp (car result)))
+ (should (integerp (cdr result)))
+ (should (cl-plusp (cdr result)))
+ (should (time-equal-p result (time-add input '(0 0 0 1000))))))))
(ert-deftest mod-test-add-nanosecond/nil ()
(should (<= (float-time (mod-test-add-nanosecond nil))