Path: csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.002 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'python.': 0.02; 'python,': 0.02; 'subject:Python': 0.06; 'received:198': 0.07; '*is*': 0.09; 'abstraction': 0.09; 'boundaries.': 0.09; 'conversions': 0.09; 'things,': 0.09; 'python': 0.11; 'jan': 0.12; 'question.': 0.14; '(either': 0.16; 'helps.': 0.16; 'how,': 0.16; 'none.': 0.16; 'roy': 0.16; 'simple.': 0.16; 'timestamp': 0.16; 'utc': 0.16; 'utc.': 0.16; ':-)': 0.16; 'wrote:': 0.18; 'trying': 0.19; 'thu,': 0.19; 'select': 0.22; 'header:User-Agent:1': 0.23; "i've": 0.25; 'header:In-Reply-To:1': 0.27; 'point': 0.28; 'chris': 0.29; 'unix': 0.29; "i'm": 0.30; 'code': 0.31; 'argue': 0.31; 'object.': 0.31; 'writes:': 0.31; 'know.': 0.32; 'maybe': 0.34; 'skip:d 20': 0.34; 'subject:the': 0.34; "i'd": 0.34; 'but': 0.35; 'received:google.com': 0.35; 'really': 0.36; 'representing': 0.36; 'should': 0.36; 'seconds': 0.37; 'so,': 0.37; 'easiest': 0.38; 'stable': 0.38; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'obtain': 0.39; 'to:addr:python.org': 0.39; 'called': 0.40; 'how': 0.40; 'even': 0.60; 'skip:u 10': 0.60; 'hope': 0.61; 'simple': 0.61; "you're": 0.61; 'times': 0.62; 'show': 0.63; 'more': 0.64; 'smith': 0.68; 'article': 0.77; 'message-id:@mx.google.com': 0.80; 'asked.': 0.84; 'to/from': 0.84; 'obtained': 0.96 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:subject:in-reply-to:references:user-agent:date:message-id :mime-version:content-type; bh=P/kZtk/h6C180sOySDhTqgXEHz60mX8W5OR40vxXDgw=; b=LlJx00roZ1A0SGEuB3Pt5sy0SkPpKA8dgHuzi4MheOxNqOgNRxP+GFK4CVWqDLetMB ZScYm8jNv3ck5PUdpjpmgQXYShrjf503zv2wcgXDZVRsg44dEvij5Nggsi+4o0X08wud bk+L5AvDrxWnIKyvaPNDZB4+jPIZOuvQXEXMYYvRfRxMo5MkLTWOb5jlTTh1bbHJS0CZ V3tzpbV+DAYXbJtSZnuRP46zHyrrYiv2lF+usKWf00oXKKfQDQT/tigomhkVGSHXXX+s APW4u0p8IdCyToKwt9p81SCU0U8iDfzf08AnL8jibpYZBSVBkjICecrDUc5z0Q6S/h3O m62A== X-Received: by 10.49.109.200 with SMTP id hu8mr3413799qeb.72.1389247598720; Wed, 08 Jan 2014 22:06:38 -0800 (PST) From: Kushal Kumaran To: python-list@python.org Subject: Re: the Gravity of Python 2 In-Reply-To: References: <78d91$52cbf8e9$541826b9$29485@cache1.tilbu1.nb.home.nl> <4b702$52cc262e$541826b9$22985@cache80.multikabel.net> <4cbf$52cc2e82$541826b9$11761@cache70.multikabel.net> <686$52cd4640$541826b9$21896@cache1.tilbu1.nb.home.nl> User-Agent: Notmuch/0.17+7~gc734dd7 (http://notmuchmail.org) Emacs/24.3.1 (x86_64-pc-linux-gnu) Date: Thu, 09 Jan 2014 11:36:29 +0530 MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha1; protocol="application/pgp-signature" X-Mailman-Approved-At: Thu, 09 Jan 2014 09:43:12 +0100 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 79 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1389256993 news.xs4all.nl 2965 [2001:888:2000:d::a6]:52332 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:63583 --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable Roy Smith writes: > In article , > Chris Angelico wrote: > >> On Thu, Jan 9, 2014 at 2:35 PM, Roy Smith wrote: >> >> Yes, it *is* simple. It *is* easy. I've been working with pure-UTC >> >> times (either called time_t, or TIMESTAMP WITH TIME ZONE, or even just >> >> float) for decades. Like with so many other things, the easiest >> >> solution is also the best, because you can just work with one stable >> >> representation and abstraction on the inside, with conversions to/from >> >> it at the boundaries. It IS that easy. >> > >> > Please show me the simple code to obtain an aware UTC datetime >> > representing the current time. >>=20 >> In Pike: >> time(); >>=20 >> In PostgreSQL: >> SELECT now(); >>=20 >> In C: >> time(0); >>=20 >> All of these give a value in UTC. > > None of which answer my question. How, in Python, do you get an aware=20 > UTC datetime object? I know how to get a numeric representation of the=20 > time as the number of seconds since the Unix epoch. That's not what I=20 > asked. > My local copy of the python 3.2.3 docs says: classmethod datetime.utcnow() Return the current UTC date and time, with tzinfo None. This is like now(), but returns the current UTC date and time, as a naive datetime object. An aware current UTC datetime can be obtained by calling datetime.now(timezone.utc). See also now(). Hope this helps. >> So maybe the key is to use utcfromtimestamp()? I don't know. > > So, I'm really confused what point you're trying to make. You started=20 > out arguing that I should be using aware datetimes instead of naive=20 > datetimes. I said that the reason I don't use aware datetimes is=20 > because they're so much more difficult to generate. You said they were=20 > simple to generate. > > So, I'd like to see your code which generates an aware UTC datetime=20 > object in Python. And then we can argue about whether it's simple or=20 > not :-) =2D-=20 regards, kushal --=-=-= Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.14 (GNU/Linux) iQEcBAEBAgAGBQJSzjxlAAoJEKolkdITDqLtz1QIAISsuh8oZAEkaI15u70BygGy ZpdmON5DnZAIXDeF9LVSZH4QWfIuZ8edaS8KUyAq8SsbU5p+cxNX/lwkq1iDTCLb QOYQ9SVTKE0ODx8Y1bq4CqOZml+NUur5vEJB9kwuTV6iYO5HiO+0F+2jC2jAHFwJ 7KalQe76vxUzxYbKyflkjvvb9NtVGk5z4ruBcrjtimweUJE4FKyPMF6RsN2FPJCo 8BenzLBCs8Ojx5Gw1+FrNTWjLDgeNcRG9n3NMTVRcaDGWxC5JwIzXTN3XXntYUs9 qoe843oWK8ff6SGFxACyDa4Vee1ek9w/4P4ItMmPBCqoYahHw621fdFuGR8KT/k= =4h1b -----END PGP SIGNATURE----- --=-=-=--