[delightful new insight elided, all summarized by what remains ;-) ] [Tim] >> What somedatetime+timedelta really does is simpler than that: it >> adds the number of microseconds represented by the timedelta to >> somedatetime,
[Lennart]] > No it doesn't. Lennart, I wrote the code. Both the Python and C datetime implementations. I know exactly what it does, and these repetitive denials can't change that. Well, maybe they can. I really am just assuming they can't ;-) Here's, e.g., the Python code for datetime.__add__: def __add__(self, other): "Add a datetime and a timedelta." if not isinstance(other, timedelta): return NotImplemented delta = timedelta(self.toordinal(), hours=self._hour, minutes=self._minute, seconds=self._second, microseconds=self._microsecond) delta += other hour, rem = divmod(delta.seconds, 3600) minute, second = divmod(rem, 60) if 0 < delta.days <= _MAXORDINAL: return datetime.combine(date.fromordinal(delta.days), time(hour, minute, second, delta.microseconds, tzinfo=self._tzinfo)) raise OverflowError("result out of range") There's not much to it. Apart from the year, month and date parts of `self` (which are converted to an integer number of days), all the rest is just adding integer microseconds expressed in two distinct mixed-radix systems. What part of that inspires your "No it doesn't"? It quite obviously does, if you understand the code. Your real objection (whether you realize it or not) is that it's not converting to UTC at the start and back to self._tzinfo after. But what does it matter? I'm done with this line. You can get what you want, but it has to (according to me) be done in a backward-compatible way (and see other msgs for ideas in that direction). _______________________________________________ Python-Dev mailing list Python-Dev@python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com