Skip to content

Commit 17747a0

Browse files
committed
fork_calender
1 parent 61ee048 commit 17747a0

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

Lib/calendar.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,15 @@ def weekday(year, month, day):
180180

181181

182182
def _validate_month(month):
183+
"""
184+
Validate that the month value is within the allowed range (1–12).
185+
186+
Raises:
187+
TypeError: if month is not an integer
188+
IllegalMonthError: if the month is outside the valid range
189+
"""
190+
if not isinstance(month, int):
191+
raise TypeError(f"month must be int, not {type(month).__name__}")
183192
if not 1 <= month <= 12:
184193
raise IllegalMonthError(month)
185194

@@ -832,7 +841,12 @@ def formatstring(cols, colwidth=_colwidth, spacing=_spacing):
832841

833842

834843
def timegm(tuple):
835-
"""Unrelated but handy function to calculate Unix timestamp from GMT."""
844+
"""
845+
Convert a time tuple in UTC (GMT) to seconds since the Unix epoch.
846+
847+
This function is the inverse of time.gmtime() and does not apply
848+
any timezone or daylight saving adjustments.
849+
"""
836850
year, month, day, hour, minute, second = tuple[:6]
837851
days = datetime.date(year, month, 1).toordinal() - _EPOCH_ORD + day - 1
838852
hours = days*24 + hour

0 commit comments

Comments
 (0)