summaryrefslogtreecommitdiff
path: root/src/data.c
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2019-08-05 17:38:53 -0700
committerPaul Eggert <eggert@cs.ucla.edu>2019-08-05 18:37:29 -0700
commitb06917a4912a60402025286d07d4a195749245c4 (patch)
treeae737916ce6c0296bfb88e3ba43df5c2b1ef0048 /src/data.c
parent89c63b3522b62c0fd725f0b348927a2069238452 (diff)
downloademacs-b06917a4912a60402025286d07d4a195749245c4.tar.gz
decode-time now returns subsec too
The list that decode-time returns now contains an extra trailing component that counts the subseconds part of the original timestamp (Bug#36549). This builds on a suggestion by Lars Ingebrigtsen in: https://lists.gnu.org/r/emacs-devel/2019-07/msg00734.html * doc/lispref/os.texi (Time Conversion): * doc/misc/emacs-mime.texi (time-date): * etc/NEWS: Document this. * lisp/calendar/icalendar.el (icalendar--decode-isodatetime): * lisp/calendar/iso8601.el (iso8601-parse) (iso8601-parse-time, iso8601-parse-duration) (iso8601--decoded-time): * lisp/calendar/parse-time.el (parse-time-string): * lisp/calendar/time-date.el (make-decoded-time) (decoded-time-set-defaults): * lisp/org/org.el (org-fix-decoded-time) (org-parse-time-string): * src/timefns.c (Fdecode_time): Generate subsec member for decoded time. * lisp/calendar/time-date.el (decoded-time-add) Add the decoded subsec too. * lisp/simple.el (decoded-time): New subsec member. * src/data.c (Frem): Simplify zero-check to match that of new Fmod. (integer_mod): New function, with most of the guts of the old Fmod. Remove redundant zero-check. (Fmod): Use it. * src/timefns.c (Fencode_time): Handle new subsec member or (with the obsolescent calling convention) subsec arg. It defaults to 0. * test/lisp/calendar/icalendar-tests.el: (icalendar--decode-isodatetime): * test/lisp/calendar/iso8601-tests.el (test-iso8601-date-years) (test-iso8601-date-dates, test-iso8601-date-obsolete) (test-iso8601-date-weeks, test-iso8601-date-ordinals) (test-iso8601-time, test-iso8601-combined) (test-iso8601-duration, test-iso8601-intervals) (standard-test-dates, standard-test-time-of-day-fractions) (standard-test-time-of-day-beginning-of-day) (standard-test-time-of-day-utc) (standard-test-time-of-day-zone) (standard-test-date-and-time-of-day, standard-test-interval): * test/lisp/calendar/parse-time-tests.el (parse-time-tests): * test/src/timefns-tests.el (format-time-string-with-zone) (encode-time-dst-numeric-zone): Adjust to match new behavior.
Diffstat (limited to 'src/data.c')
-rw-r--r--src/data.c40
1 files changed, 20 insertions, 20 deletions
diff --git a/src/data.c b/src/data.c
index 46bd7e0e253..6db8ea144dd 100644
--- a/src/data.c
+++ b/src/data.c
@@ -3067,7 +3067,7 @@ Both must be integers or markers. */)
CHECK_INTEGER_COERCE_MARKER (y);
/* A bignum can never be 0, so don't check that case. */
- if (FIXNUMP (y) && XFIXNUM (y) == 0)
+ if (EQ (y, make_fixnum (0)))
xsignal0 (Qarith_error);
if (FIXNUMP (x) && FIXNUMP (y))
@@ -3081,30 +3081,14 @@ Both must be integers or markers. */)
}
}
-DEFUN ("mod", Fmod, Smod, 2, 2, 0,
- doc: /* Return X modulo Y.
-The result falls between zero (inclusive) and Y (exclusive).
-Both X and Y must be numbers or markers. */)
- (register Lisp_Object x, Lisp_Object y)
+/* Return X mod Y. Both must be integers and Y must be nonzero. */
+Lisp_Object
+integer_mod (Lisp_Object x, Lisp_Object y)
{
- CHECK_NUMBER_COERCE_MARKER (x);
- CHECK_NUMBER_COERCE_MARKER (y);
-
- /* Note that a bignum can never be 0, so we don't need to check that
- case. */
- if (FIXNUMP (y) && XFIXNUM (y) == 0)
- xsignal0 (Qarith_error);
-
- if (FLOATP (x) || FLOATP (y))
- return fmod_float (x, y);
-
if (FIXNUMP (x) && FIXNUMP (y))
{
EMACS_INT i1 = XFIXNUM (x), i2 = XFIXNUM (y);
- if (i2 == 0)
- xsignal0 (Qarith_error);
-
i1 %= i2;
/* If the "remainder" comes out with the wrong sign, fix it. */
@@ -3128,6 +3112,22 @@ Both X and Y must be numbers or markers. */)
}
}
+DEFUN ("mod", Fmod, Smod, 2, 2, 0,
+ doc: /* Return X modulo Y.
+The result falls between zero (inclusive) and Y (exclusive).
+Both X and Y must be numbers or markers. */)
+ (Lisp_Object x, Lisp_Object y)
+{
+ CHECK_NUMBER_COERCE_MARKER (x);
+ CHECK_NUMBER_COERCE_MARKER (y);
+
+ /* A bignum can never be 0, so don't check that case. */
+ if (EQ (y, make_fixnum (0)))
+ xsignal0 (Qarith_error);
+
+ return (FLOATP (x) || FLOATP (y) ? fmod_float : integer_mod) (x, y);
+}
+
static Lisp_Object
minmax_driver (ptrdiff_t nargs, Lisp_Object *args,
enum Arith_Comparison comparison)