File tree Expand file tree Collapse file tree 1 file changed +3
-0
lines changed Expand file tree Collapse file tree 1 file changed +3
-0
lines changed Original file line number Diff line number Diff line change @@ -65,6 +65,7 @@ def self.leap_days(year)
6565
6666 # perform lookup by month number and year, one-indexed, with leap days
6767 def self . month_days ( month , year )
68+ raise ( InvalidMonth , month . inspect ) unless ( 1 ..12 ) . cover? ( month )
6869 ( month == 2 and self . leap_year? ( year ) ) ?
6970 MON29 : MONTH_DAYS . fetch ( month - 1 )
7071 end
@@ -77,6 +78,7 @@ def self.guess_month(days)
7778
7879 # perform lookup by month number and year, one-indexed, with leap days
7980 def self . cumulative_days ( month , year )
81+ raise ( InvalidMonth , month . inspect ) unless ( 1 ..12 ) . cover? ( month )
8082 days = CUMULATIVE_DAYS . fetch ( month - 1 )
8183 ( month > 2 and self . leap_year? ( year ) ) ? ( days + 1 ) : days
8284 end
@@ -167,6 +169,7 @@ def self.month_number(name)
167169
168170 # perform lookup of month name by month number, one-indexed
169171 def self . month_name ( number )
172+ raise ( InvalidMonth , number . inspect ) unless ( 1 ..12 ) . cover? ( number )
170173 MONTH_NAMES . fetch ( number - 1 )
171174 end
172175
You can’t perform that action at this time.
0 commit comments