Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #41081

Re: Why are timezone aware and naive datetimes not distinct classes?

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!ecngs!feeder2.ecngs.de!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <awilliam@whitemice.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.004
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'debugging': 0.05; 'developer,': 0.05; 'sanity': 0.07; 'python': 0.09; 'subject:Why': 0.09; 'subject:not': 0.11; 'adam': 0.16; 'from:addr:awilliam': 0.16; 'from:addr:whitemice.org': 0.16; 'from:name:adam tauno williams': 0.16; 'gpg': 0.16; 'received:72.14.190': 0.16; 'received:72.14.190.87': 0.16; 'received:mail.wmmi.net': 0.16; 'received:wmmi.net': 0.16; 'reply-to:addr:awilliam': 0.16; 'reply- to:addr:whitemice.org': 0.16; 'roy': 0.16; 'utc': 0.16; 'wrote:': 0.17; 'received:72.14': 0.20; 'posted': 0.22; 'cc:2**0': 0.23; 'elements': 0.23; 'errors': 0.23; "i've": 0.23; 'pass': 0.25; 'tried': 0.25; 'header:In-Reply-To:1': 0.25; 'convert': 0.29; 'fri,': 0.30; 'url:2012': 0.30; 'error': 0.30; '(and': 0.32; 'getting': 0.33; 'turns': 0.33; 'problem': 0.33; 'to:addr:python- list': 0.33; 'list': 0.35; 'subject:?': 0.35; 'subject:: ': 0.38; 'some': 0.38; 'things': 0.38; 'page': 0.38; 'to:addr:python.org': 0.39; 'received:192': 0.39; 'received:192.168': 0.40; 'story': 0.61; 'here:': 0.62; 'management': 0.65; 'tricks': 0.65; 'url:10': 0.65; 'finally': 0.66; 'life': 0.66; 'header:Reply-To:1': 0.68; 'smith': 0.71; 'reply-to:no real name:2**0': 0.72; 'verifying': 0.84
Subject Re: Why are timezone aware and naive datetimes not distinct classes?
From Adam Tauno Williams <awilliam@whitemice.org>
To python-list@python.org
Date Mon, 11 Mar 2013 13:27:11 -0400
In-Reply-To <roy-3BFD51.13412708032013@70-1-84-166.pools.spcsdns.net>
References <roy-3BFD51.13412708032013@70-1-84-166.pools.spcsdns.net>
Content-Type text/plain; charset="ISO-8859-1"
X-Mailer Evolution 3.6.3
Mime-Version 1.0
Content-Transfer-Encoding 7bit
Cc Roy Smith <roy@panix.com>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
Reply-To awilliam@whitemice.org
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.3199.1363024033.2939.python-list@python.org> (permalink)
Lines 32
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1363024033 news.xs4all.nl 6857 [2001:888:2000:d::a6]:46336
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:41081

Show key headers only | View raw


On Fri, 2013-03-08 at 13:41 -0500, Roy Smith wrote:
> To make a long (and painful) story short, I've got a (large) list of 
> datetimes, and was getting some bizarre errors working with it.  One of 
> the things I tried while debugging the problem was verifying that all 
> the elements of the list were indeed datetimes:
> In [59]:  set(type(foo) for foo in x)
> Out[59]:  set([datetime.datetime]

Because date/time management in Python is *@*&@R&*(R *@&Y terrible!
Period, full-stop, awful, crappy, lousy, and aggravating.  The design is
haphazard and error inducing.

Pass through the list once and convert them all the UTC [or I suppose,
make them all naive].

BTW, this page is a life and sanity saver:

<http://taaviburns.ca/what_you_need_to_know_about_datetimes/datetime_transforms.html>

And one of my own tricks is posted here:

<http://www.whitemiceconsulting.com/2012/10/setting-course-for-utc.html>

> Well, it turns out, one of them was a timezone-aware datetime, and all 
> the others were naive!  I finally figured it out when I tried

Welcome!

-- 
Adam Tauno Williams  GPG D95ED383
Systems Administrator, Python Developer, LPI / NCLA

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Why are timezone aware and naive datetimes not distinct classes? Roy Smith <roy@panix.com> - 2013-03-08 13:41 -0500
  Re: Why are timezone aware and naive datetimes not distinct classes? Nobody <nobody@nowhere.com> - 2013-03-08 21:33 +0000
    Re: Why are timezone aware and naive datetimes not distinct classes? Chris Angelico <rosuav@gmail.com> - 2013-03-09 09:01 +1100
      Re: Why are timezone aware and naive datetimes not distinct classes? Nobody <nobody@nowhere.com> - 2013-03-09 19:14 +0000
        Re: Why are timezone aware and naive datetimes not distinct classes? Roy Smith <roy@panix.com> - 2013-03-09 14:40 -0500
          Re: Why are timezone aware and naive datetimes not distinct classes? Nobody <nobody@nowhere.com> - 2013-03-09 23:38 +0000
        Re: Why are timezone aware and naive datetimes not distinct classes? Chris Angelico <rosuav@gmail.com> - 2013-03-10 09:28 +1100
  Re: Why are timezone aware and naive datetimes not distinct classes? Adam Tauno Williams <awilliam@whitemice.org> - 2013-03-11 13:27 -0400
    Re: Why are timezone aware and naive datetimes not distinct classes? djc <djc@kangoo.invalid> - 2013-03-11 20:32 +0000

csiph-web