diff options
| author | Alex Branham | 2020-03-24 19:34:14 -0400 |
|---|---|---|
| committer | Eli Zaretskii | 2020-04-03 14:15:31 +0300 |
| commit | f134dfa041b30a8c28484a13c2fa08f2fee27ff5 (patch) | |
| tree | 3f617c21a88881d2297ef9f407c3fb0adf66099d /lisp | |
| parent | f28166dc9a56111606be8ac50ad38179a66ea636 (diff) | |
| download | emacs-f134dfa041b30a8c28484a13c2fa08f2fee27ff5.tar.gz emacs-f134dfa041b30a8c28484a13c2fa08f2fee27ff5.zip | |
Error out if 'date-days-in-month' is given an invalid month
* 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.
Diffstat (limited to 'lisp')
| -rw-r--r-- | lisp/calendar/time-date.el | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/lisp/calendar/time-date.el b/lisp/calendar/time-date.el index e2402de8010..9b58a4884bc 100644 --- a/lisp/calendar/time-date.el +++ b/lisp/calendar/time-date.el | |||
| @@ -355,6 +355,8 @@ is output until the first non-zero unit is encountered." | |||
| 355 | 355 | ||
| 356 | (defun date-days-in-month (year month) | 356 | (defun date-days-in-month (year month) |
| 357 | "The number of days in MONTH in YEAR." | 357 | "The number of days in MONTH in YEAR." |
| 358 | (unless (<= 1 month 12) | ||
| 359 | (error "Month %s invalid" month)) | ||
| 358 | (if (= month 2) | 360 | (if (= month 2) |
| 359 | (if (date-leap-year-p year) | 361 | (if (date-leap-year-p year) |
| 360 | 29 | 362 | 29 |