[Zope3-dev] Re: [Python-Dev] Holes in time
Guido van Rossum
guido@python.org
Sat, 04 Jan 2003 01:57:00 -0500
> So, at the moment, I don't have an actual use case in hand anymore that
> requires a from_utc() method. astimezone() could be written in terms of it,
> though:
>
> def astimezone(self, tz):
> self -= self.utcoffset() # as UTC
> other = self.replace(tzinfo=tz)
> return other.from_utc()
>
> and the tzinfo base class could supply a default from_utc() method capturing
> the current astimezone() implementation. Then we'd have a powerful hook
> tzinfo subclasses could override -- but I'm not sure anyone will find a need
> to!
That's a potentially powerful idea (but call it fromutc() since
utcoffset() doesn't have an underscore either). I'd also then perhaps
favor the idea of implementing utcoffset() in that base class as
returning a fixed standard offset plus whatever dst() returns --
though that requires us to fix the name and type of the offset, and
may require a special case for when dst() returns None, so maybe it's
not worth it.
--Guido van Rossum (home page: http://www.python.org/~guido/)