Path: csiph.com!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail From: Carl Meyer Newsgroups: comp.lang.python Subject: Re: Missing something about timezones Date: Mon, 14 Mar 2016 10:12:24 -0600 Lines: 63 Message-ID: References: Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="OI7qkuSh4vNObvFTTITVJ3g0U4ksAloNP" X-Trace: news.uni-berlin.de QqZaF3WUsIbjUDz0mmGeJgGv5uyCPC5tEmqkwZoSdTFw== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.011 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'that?': 0.05; 'dst': 0.07; 'skip:` 30': 0.09; '10:26': 0.16; '2016': 0.16; 'filename:fname piece:signature': 0.16; 'from:addr:carl': 0.16; 'received:173.255': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'wrote:': 0.16; 'skip': 0.18; 'thanks.': 0.18; '>>>': 0.20; 'chicago': 0.22; 'implicit': 0.22; 'am,': 0.23; 'import': 0.24; 'header:In-Reply-To:1': 0.24; 'mon,': 0.24; 'header:User-Agent:1': 0.26; '14,': 0.27; 'reflect': 0.27; "skip:' 10": 0.28; '13,': 0.29; 'asked': 0.29; 'relative': 0.30; 'supposed': 0.31; 'correctly': 0.34; 'handle': 0.34; 'skip:d 20': 0.34; 'skip:p 30': 0.35; 'but': 0.36; 'should': 0.36; 'there': 0.36; 'to:addr:python- list': 0.36; 'subject:: ': 0.37; 'received:org': 0.37; 'thought': 0.37; 'why': 0.39; 'does': 0.39; "didn't": 0.39; 'to:addr:python.org': 0.40; 'some': 0.40; "you'll": 0.61; 'charset:windows-1252': 0.62; 'mar': 0.65; 'savings.': 0.66; 'account': 0.66; '09:32': 0.84 X-Enigmail-Draft-Status: N1110 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.6.0 In-Reply-To: X-Spam-Status: No (score -1.0): ALL_TRUSTED=-1 X-Spam-Bar: - X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Xref: csiph.com comp.lang.python:104837 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --OI7qkuSh4vNObvFTTITVJ3g0U4ksAloNP Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable Hi Skip, On 03/14/2016 09:32 AM, Skip Montanaro wrote: > On Mon, Mar 14, 2016 at 10:26 AM, Ian Kelly wro= te: >> Why should it? You only asked pytz for the Chicago timezone. You >> didn't ask for it relative to any specific time. >=20 > Thanks. I thought using America/Chicago was supposed to automagically > take into account transitions into and out of Daylight Savings. Is > there some way to get that? Yes, pytz can handle DST correctly automatically when you give it 'America/Chicago', but until you apply that timezone to a particular datetime, there is no DST to handle. There is no implicit assumption of "today" when you do `pytz.timezone('America/Chicago'). If you apply the timezone to a particular datetime, you'll see that it does reflect DST correctly: >>> import datetime, pytz >>> tz =3D pytz.timezone('America/Chicago') >>> tz >>> import datetime >>> dt =3D datetime.datetime.now() >>> dtl =3D tz.localize(dt) >>> dtl datetime.datetime(2016, 3, 14, 10, 11, 13, 514375, tzinfo=3D) Carl --OI7qkuSh4vNObvFTTITVJ3g0U4ksAloNP Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.22 (GNU/Linux) iQIcBAEBCAAGBQJW5uLsAAoJEC0ft5FqUuEhpTgP/iIPL5qdt46sXTyt4Vz5yERj 6d1WEzeNhFkrTQfLwpRgLCkuzR4uTGlwnpShHQJ/3gXbvYQP6+xnSdm+7NYwc5LJ oQyMTDbF+krFpnHWQzt/sw4esbZopO2zV6EYRdNuVdfloE3bjd/8Yqu578vCe6gS P+TkTK7zPvCSFXGNhjfX9FP8nQFVhcCMIH+DwlOF0tK51fXmVdEV/bwbuiW30jUu fDpQnB8O0Y6MdzjzZXq4q1TEVyhPd2N/QnDrBFxmPasxMASxoKTDjiKc1uA1zKrx +85DwtywNQZeJ5+QQ/QMPDokMwjhRhr0+fbj+qSNcnxwJSO4vjpnz4SE3qTxQDIG XjGhn6PxNNDGUeDUa882smiJVEx6hn+dfkTybYUYdJTaj3EoP2f8Feu4B62VmmiT r2wUsPLr1j1IGQNu4uvOzyFB7dr8qAORMqAmhrB8sUdOelvp+CT5orhcfwEdHnTz vEjO25OWJhDCcfSFprVJ4mhU3HfkhJXzfCrTNwj90gw1RXcGpKKV76L5V+qgnbnn FPUtarMOAxgvEWGl3V98y/6YDTEuqLSPWs3Q2ReFVmHcU0FBY3ODAByw9ilm0ajL MzxS459j/GD5Z6cbDrBf9KFZnH/igwtO419eWDKPsd3Llng2WRSz7sgcqf/eujy5 Y5bjRS4eXvM/oltWEIR/ =CKCA -----END PGP SIGNATURE----- --OI7qkuSh4vNObvFTTITVJ3g0U4ksAloNP--