Why are timezone aware and naive datetimes not distinct classes?

Chris Angelico rosuav at gmail.com
Sat Mar 9 23:28:32 CET 2013

On Sun, Mar 10, 2013 at 6:14 AM, Nobody <nobody at nowhere.com> wrote:
> On Sat, 09 Mar 2013 09:01:17 +1100, Chris Angelico wrote:
>> As I see it, a naive datetime simply does not have a timezone.
> The distinction between aware and naive isn't whether the .tzinfo member
> is None, but whether self.utcoffset() returns None (which can occur either
> if self.tzinfo is None or if self.tzinfo.utcoffset(self) returns None).
> IOW, an "aware" time/datetime can be converted to a UTC time/datetime, a
> "naive" one can't, although it can still have a timezone which isn't
> referenced to UTC.

I stand corrected. Though the distinction I made in my first paragraph
is still valid: an aware datetime represents an instant in time, a
naive one is a tagged piece of arbitrary data.

On Sun, Mar 10, 2013 at 6:40 AM, Roy Smith <roy at panix.com> wrote:
> Future scheduled activities (which I assume is what you
> mean by "appointments") should be kept in whatever timezone makes sense
> for that activity.

Agreed; and in some specific circumstances, it's even possible to
fight the whole mess of timezones. My online Dungeons and Dragons
group schedules everything on UTC - for example, the server quotes the
current time as Sat 22:26, and I have a session at Sun 02:00, so
anyone can figure out how long until session without worrying about
timezones or Daylight Robbery Time. Of course, that _does_ come at a
cost; mainly it's the USA-based players who get confused (which
surprises me somewhat, tbh).


More information about the Python-list mailing list