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


Groups > comp.lang.python > #57373

Confused about timezones

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <skip.montanaro@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.010
X-Spam-Evidence '*H*': 0.98; '*S*': 0.00; 'python.': 0.02; 'dst': 0.09; 'python': 0.11; 'from:addr:pobox.com': 0.16; 'from:addr:skip': 0.16; 'sequence:': 0.16; 'utc': 0.16; 'sender:addr:gmail.com': 0.17; '>>>': 0.22; 'import': 0.22; 'issue,': 0.24; 'skip': 0.24; 'skip:l 30': 0.24; 'gets': 0.27; 'skip:p 30': 0.29; 'message-id:@mail.gmail.com': 0.30; 'correctly.': 0.31; 'implemented': 0.33; 'skip:d 20': 0.34; 'problem': 0.35; 'objects': 0.35; 'received:google.com': 0.35; 'really': 0.36; 'clear': 0.37; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'how': 0.40; '30,': 0.65; 'past,': 0.68
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:date:message-id:subject:from:to:content-type; bh=8XtRzB9QO8p+qedT4apeZGAmnqXDpjY01kD7S+pfqpM=; b=tEMMaE2HbUrjpldB1zxVUTlELbI4GSniP5nofpZHM22ckqAz8HZbSsAhyrHTHCl7ku 0cG+QF/35x8KzKC3CTbj3avDm/P1V/UVyqKtnCGIzhf8ETv06BlwrWCf2hW6YqZafCSc eVk6123cpwy9UziZ3BlP6UMPY5TT9LW2Bpx6/lK14c2JBWELaE0gY9/Ju9uUP0RBo4nR la59C2a66Eni7kCgQmFt78tZx1laDS3AQnnp7C0u/7k3Cm5b81IjNEjto7QaFJzJHHDy rrbql7dx7QNi056wvOi7zVFhXhyNB9tkFUHvdrEKOJT/Obe4TI4sZf7Wo3t+a1bBjbmI xBNg==
MIME-Version 1.0
X-Received by 10.50.120.10 with SMTP id ky10mr1594486igb.29.1382545036122; Wed, 23 Oct 2013 09:17:16 -0700 (PDT)
Sender skip.montanaro@gmail.com
Date Wed, 23 Oct 2013 11:17:16 -0500
X-Google-Sender-Auth ZWiqt_otVNIzLwqR3GKovXPiSjs
Subject Confused about timezones
From Skip Montanaro <skip@pobox.com>
To Python <python-list@python.org>
Content-Type text/plain; charset=UTF-8
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://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 <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.1416.1382545517.18130.python-list@python.org> (permalink)
Lines 20
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1382545517 news.xs4all.nl 15999 [2001:888:2000:d::a6]:52841
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:57373

Show key headers only | View raw


This isn't really a Python issue, though my problem solution will be
implemented in Python. If I have a naive datetime object for some time
in the past, it's not clear to me how the offset gets set correctly.
Consider this sequence:

>>> import datetime, pytz
>>> LOCAL_TZ = pytz.timezone(os.environ.get('TZ', "America/Chicago"))
>>> dt1 = datetime.datetime(2013, 5, 30, 0, 0) # DST in effect
>>> dt2 = datetime.datetime(2013, 1, 30, 0, 0) # no DST
>>> LOCAL_TZ.localize(dt1).utcoffset()
datetime.timedelta(-1, 68400)
>>> LOCAL_TZ.localize(dt2).utcoffset()
datetime.timedelta(-1, 64800)

Why is the UTC offset the same for both datetime objects despite the
presence/absence of Daylight Savings?

Thx,

Skip

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


Thread

Confused about timezones Skip Montanaro <skip@pobox.com> - 2013-10-23 11:17 -0500

csiph-web