GNU bug report logs -
#40217
28.0.50; Add check for valid month to date-days-in-month
Previous Next
Reported by: Alex Branham <alex.branham <at> gmail.com>
Date: Tue, 24 Mar 2020 23:40:01 UTC
Severity: minor
Tags: patch
Found in version 28.0.50
Done: Eli Zaretskii <eliz <at> gnu.org>
Bug is archived. No further changes may be made.
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 40217 in the body.
You can then email your comments to 40217 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#40217
; Package
emacs
.
(Tue, 24 Mar 2020 23:40:01 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Alex Branham <alex.branham <at> gmail.com>
:
New bug report received and forwarded. Copy sent to
bug-gnu-emacs <at> gnu.org
.
(Tue, 24 Mar 2020 23:40:01 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
Hello -
Here's a patch that adds a check for whether the month argument is
valid in the new date-days-in-month function. It currently returns 30
for a month value of, say, 15.
Thanks,
Alex
[0001-Add-check-for-valid-month-to-date-days-in-month.patch (text/x-patch, inline)]
From f9c3040d516314209d64738fd23deafc5eb59faa Mon Sep 17 00:00:00 2001
From: Alex Branham <alex.branham <at> gmail.com>
Date: Tue, 24 Mar 2020 19:34:14 -0400
Subject: [PATCH] Add check for valid month to date-days-in-month
* lisp/calendar/time-date.el (date-days-in-month): Add check.
* test/lisp/calendar/time-date-tests.el (test-days-in-month): Add test
for new error.
---
lisp/calendar/time-date.el | 2 ++
test/lisp/calendar/time-date-tests.el | 3 ++-
2 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/lisp/calendar/time-date.el b/lisp/calendar/time-date.el
index e2402de801..9b58a4884b 100644
--- a/lisp/calendar/time-date.el
+++ b/lisp/calendar/time-date.el
@@ -355,6 +355,8 @@ seconds-to-string
(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
diff --git a/test/lisp/calendar/time-date-tests.el b/test/lisp/calendar/time-date-tests.el
index 4c8f18a7a9..9c90300cfe 100644
--- a/test/lisp/calendar/time-date-tests.el
+++ b/test/lisp/calendar/time-date-tests.el
@@ -31,7 +31,8 @@ test-leap-year
(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)
--
2.25.1
Added tag(s) patch.
Request was from
Noam Postavsky <npostavs <at> gmail.com>
to
control <at> debbugs.gnu.org
.
(Tue, 31 Mar 2020 22:58:01 GMT)
Full text and
rfc822 format available.
Severity set to 'minor' from 'normal'
Request was from
Noam Postavsky <npostavs <at> gmail.com>
to
control <at> debbugs.gnu.org
.
(Tue, 31 Mar 2020 22:58:01 GMT)
Full text and
rfc822 format available.
Reply sent
to
Eli Zaretskii <eliz <at> gnu.org>
:
You have taken responsibility.
(Fri, 03 Apr 2020 11:23:02 GMT)
Full text and
rfc822 format available.
Notification sent
to
Alex Branham <alex.branham <at> gmail.com>
:
bug acknowledged by developer.
(Fri, 03 Apr 2020 11:23:02 GMT)
Full text and
rfc822 format available.
Message #14 received at 40217-done <at> debbugs.gnu.org (full text, mbox):
> From: Alex Branham <alex.branham <at> gmail.com>
> Date: Tue, 24 Mar 2020 19:39:44 -0400
>
> Here's a patch that adds a check for whether the month argument is
> valid in the new date-days-in-month function. It currently returns 30
> for a month value of, say, 15.
Thanks, pushed to the master branch (after some minor fixes of the
commit log message).
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Fri, 01 May 2020 11:24:05 GMT)
Full text and
rfc822 format available.
This bug report was last modified 3 years and 361 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.