* lisp/calendar/time-date.el (date-days-in-month): Improve the
error message text and make sure MONTH is a number. (Bug#40217)
(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
(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)