Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #56495 > unrolled thread
| Started by | Skip Montanaro <skip@pobox.com> |
|---|---|
| First post | 2013-10-09 10:15 -0500 |
| Last post | 2013-10-09 10:15 -0500 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.python
datetime.timedelta.replace? Skip Montanaro <skip@pobox.com> - 2013-10-09 10:15 -0500
| From | Skip Montanaro <skip@pobox.com> |
|---|---|
| Date | 2013-10-09 10:15 -0500 |
| Subject | datetime.timedelta.replace? |
| Message-ID | <mailman.897.1381331756.18130.python-list@python.org> |
Datetime objects have a replace method, but timedelta objects don't. If I take the diff of two datetimes and want to zero out the microseconds field, is there some way to do it more cleanly than this? delta = dt1 - dt2 zero_delta = datetime.timedelta(days=delta.days, seconds=delta.seconds) I guess that's not bad, but replace() seems cleaner (or at least more congruent with datetime objects). Skip
Back to top | Article view | comp.lang.python
csiph-web