* lisp/calendar/time-date.el (date-days-in-month): Add test for
month validity; signal an error if it isn't. (Bug#40217)
* test/lisp/calendar/time-date-tests.el (test-days-in-month): Add
a test for the new error.
(defun date-days-in-month (year month)
"The number of days in MONTH in YEAR."
+ (unless (<= 1 month 12)
+ (error "Month %s invalid" month))
(if (= month 2)
(if (date-leap-year-p year)
29
(ert-deftest test-days-in-month ()
(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-not (= (date-days-in-month 1900 3) 28))
+ (should-error (date-days-in-month 2020 15)))
(ert-deftest test-ordinal ()
(should (equal (date-ordinal-to-time 2008 271)