> >>> now.replace(month=2, day=30) > Traceback (most recent call last): > File "<stdin>", line 1, in ? > ValueError: day is out of range for month > >>> > > This makes operations like "move to the end of the current month" > non-trivial (not *hard*, just non-trivial). If I were designing something like this, I think I would approach it quite differently, and provide a bunch of separate functions or methods that transform dates in specific ways. e.g. end_of_month(d) forward_months(n, d) then to "go to the end of the month 3 months from now" would be end_of_month(forward_months(3, d)) or, if you prefer a method-chaining style, d.forward_months(3).end_of_month() Greg Ewing, Computer Science Dept, +--------------------------------------+ University of Canterbury, | A citizen of NewZealandCorp, a | Christchurch, New Zealand | wholly-owned subsidiary of USA Inc. | greg at cosc.canterbury.ac.nz +--------------------------------------+
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4