[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master d8dae04 2/2: Improve last change
From: |
Eli Zaretskii |
Subject: |
master d8dae04 2/2: Improve last change |
Date: |
Fri, 3 Apr 2020 07:21:59 -0400 (EDT) |
branch: master
commit d8dae04e5ae5cc4897c8d1af8548a0c1576137b6
Author: Eli Zaretskii <address@hidden>
Commit: Eli Zaretskii <address@hidden>
Improve last change
* lisp/calendar/time-date.el (date-days-in-month): Improve the
error message text and make sure MONTH is a number. (Bug#40217)
---
lisp/calendar/time-date.el | 4 ++--
test/lisp/calendar/time-date-tests.el | 3 ++-
2 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/lisp/calendar/time-date.el b/lisp/calendar/time-date.el
index 9b58a48..eeb0992 100644
--- a/lisp/calendar/time-date.el
+++ b/lisp/calendar/time-date.el
@@ -355,8 +355,8 @@ is output until the first non-zero unit is encountered."
(defun date-days-in-month (year month)
"The number of days in MONTH in YEAR."
- (unless (<= 1 month 12)
- (error "Month %s invalid" month))
+ (unless (and (numberp month) (<= 1 month 12))
+ (error "Month %s is invalid" month))
(if (= month 2)
(if (date-leap-year-p year)
29
diff --git a/test/lisp/calendar/time-date-tests.el
b/test/lisp/calendar/time-date-tests.el
index 9c90300..3eecc67 100644
--- a/test/lisp/calendar/time-date-tests.el
+++ b/test/lisp/calendar/time-date-tests.el
@@ -32,7 +32,8 @@
(should (= (date-days-in-month 2004 2) 29))
(should (= (date-days-in-month 2004 3) 31))
(should-not (= (date-days-in-month 1900 3) 28))
- (should-error (date-days-in-month 2020 15)))
+ (should-error (date-days-in-month 2020 15))
+ (should-error (date-days-in-month 2020 'foo)))
(ert-deftest test-ordinal ()
(should (equal (date-ordinal-to-time 2008 271)