פתרתי את התרגיל לכאורה, והוא רץ כאשר אני מכניסה בתור קלט תאריכים מסוימים.
אך כאשר אני מריצה אותו עם התאריכים שניתנו כדוגמה בתרגיל (1912-06-23, 1954-06-07), מתקבלת השגיאה הבאה (date1 הוא תאריך מסוג datetime.datetime):
—> 15 date1_timestamp = date1.timestamp()
OSError: [Errno 22] Invalid argument
עפ"י הדוקומנטציה (של fromtimestamp), נראה שיש בעיה עם שנים שחורגות מטווח מסוים:
classmethod date.fromtimestamp(timestamp)
Return the local date corresponding to the POSIX timestamp, such as is returned by time.time().This may raise OverflowError, if the timestamp is out of the range of values supported by the platform C localtime() function, and OSError on localtime() failure. It’s common for this to be restricted to years from 1970 through 2038. Note that on non-POSIX systems that include leap seconds in their notion of a timestamp, leap seconds are ignored by fromtimestamp().
האם חלק מהתרגיל הוא להתמודד עם שנים מחוץ לטווח שמוגדר במודול? אשמח להכוונה.
תודה!