Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #63583
| 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 | <kushal.kumaran@gmail.com> |
| 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 <kushal.kumaran@gmail.com> |
| To | python-list@python.org |
| Subject | Re: the Gravity of Python 2 |
| In-Reply-To | <roy-D3F868.23290108012014@news.panix.com> |
| References | <laf00q$10k$1@ger.gmane.org> <mailman.5098.1389053970.18130.python-list@python.org> <78d91$52cbf8e9$541826b9$29485@cache1.tilbu1.nb.home.nl> <4b702$52cc262e$541826b9$22985@cache80.multikabel.net> <4cbf$52cc2e82$541826b9$11761@cache70.multikabel.net> <mailman.5141.1389114029.18130.python-list@python.org> <686$52cd4640$541826b9$21896@cache1.tilbu1.nb.home.nl> <roy-C787B2.09153508012014@news.panix.com> <mailman.5170.1389191449.18130.python-list@python.org> <laknps$umv$1@dont-email.me> <roy-B40DB1.20273008012014@news.panix.com> <mailman.5222.1389232077.18130.python-list@python.org> <roy-956F29.21255508012014@news.panix.com> <mailman.5226.1389237436.18130.python-list@python.org> <roy-76D9D0.22351408012014@news.panix.com> <mailman.5231.1389240235.18130.python-list@python.org> <roy-D3F868.23290108012014@news.panix.com> |
| 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 <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.5245.1389256993.18130.python-list@python.org> (permalink) |
| 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 |
Show key headers only | View raw
[Multipart message — attachments visible in raw view] - view raw
Roy Smith <roy@panix.com> writes:
> In article <mailman.5231.1389240235.18130.python-list@python.org>,
> Chris Angelico <rosuav@gmail.com> wrote:
>
>> On Thu, Jan 9, 2014 at 2:35 PM, Roy Smith <roy@panix.com> 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.
>>
>> In Pike:
>> time();
>>
>> In PostgreSQL:
>> SELECT now();
>>
>> In C:
>> time(0);
>>
>> All of these give a value in UTC.
>
> None of which answer my question. How, in Python, do you get an aware
> UTC datetime object? I know how to get a numeric representation of the
> time as the number of seconds since the Unix epoch. That's not what I
> 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
> out arguing that I should be using aware datetimes instead of naive
> datetimes. I said that the reason I don't use aware datetimes is
> because they're so much more difficult to generate. You said they were
> simple to generate.
>
> So, I'd like to see your code which generates an aware UTC datetime
> object in Python. And then we can argue about whether it's simple or
> not :-)
--
regards,
kushal
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Re: the Gravity of Python 2 Chris Angelico <rosuav@gmail.com> - 2014-01-07 11:19 +1100
Re: the Gravity of Python 2 Martijn Faassen <faassen@startifact.com> - 2014-01-07 13:54 +0100
Re: the Gravity of Python 2 Martijn Faassen <faassen@startifact.com> - 2014-01-07 17:07 +0100
Re: the Gravity of Python 2 Martijn Faassen <faassen@startifact.com> - 2014-01-07 17:42 +0100
Re: the Gravity of Python 2 Chris Angelico <rosuav@gmail.com> - 2014-01-08 04:00 +1100
Re: the Gravity of Python 2 Martijn Faassen <faassen@startifact.com> - 2014-01-08 13:36 +0100
Re: the Gravity of Python 2 Chris Angelico <rosuav@gmail.com> - 2014-01-08 23:46 +1100
Re: the Gravity of Python 2 Martijn Faassen <faassen@startifact.com> - 2014-01-08 16:08 +0100
Re: the Gravity of Python 2 Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-01-09 00:01 +1100
Re: the Gravity of Python 2 Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-01-08 14:08 +0000
Re: the Gravity of Python 2 Martijn Faassen <faassen@startifact.com> - 2014-01-08 16:22 +0100
Re: the Gravity of Python 2 Chris Angelico <rosuav@gmail.com> - 2014-01-09 02:39 +1100
Re: the Gravity of Python 2 Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-01-08 15:50 +0000
Re: the Gravity of Python 2 Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-01-09 08:55 +1100
Re: the Gravity of Python 2 Roy Smith <roy@panix.com> - 2014-01-08 09:15 -0500
Re: the Gravity of Python 2 Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-01-08 14:30 +0000
Re: the Gravity of Python 2 Martijn Faassen <faassen@startifact.com> - 2014-01-08 16:26 +0100
Re: the Gravity of Python 2 Kevin Walzer <kw@codebykevin.com> - 2014-01-08 18:42 -0500
Re: the Gravity of Python 2 Roy Smith <roy@panix.com> - 2014-01-08 20:27 -0500
Re: the Gravity of Python 2 Chris Angelico <rosuav@gmail.com> - 2014-01-09 12:47 +1100
Re: the Gravity of Python 2 Roy Smith <roy@panix.com> - 2014-01-08 21:25 -0500
Re: the Gravity of Python 2 Chris Angelico <rosuav@gmail.com> - 2014-01-09 14:17 +1100
Re: the Gravity of Python 2 Roy Smith <roy@panix.com> - 2014-01-08 22:35 -0500
Re: the Gravity of Python 2 Chris Angelico <rosuav@gmail.com> - 2014-01-09 15:03 +1100
Re: the Gravity of Python 2 Roy Smith <roy@panix.com> - 2014-01-08 23:29 -0500
Re: the Gravity of Python 2 Chris Angelico <rosuav@gmail.com> - 2014-01-09 15:34 +1100
Re: the Gravity of Python 2 Chris Angelico <rosuav@gmail.com> - 2014-01-09 15:38 +1100
Re: the Gravity of Python 2 Ethan Furman <ethan@stoneleaf.us> - 2014-01-08 21:31 -0800
Re: the Gravity of Python 2 Chris Angelico <rosuav@gmail.com> - 2014-01-09 17:34 +1100
Re: the Gravity of Python 2 Ben Finney <ben+python@benfinney.id.au> - 2014-01-09 17:57 +1100
Re: the Gravity of Python 2 Chris Angelico <rosuav@gmail.com> - 2014-01-09 18:56 +1100
Re: the Gravity of Python 2 Roy Smith <roy@panix.com> - 2014-01-09 09:14 -0500
Re: the Gravity of Python 2 Chris Angelico <rosuav@gmail.com> - 2014-01-10 01:57 +1100
Re: the Gravity of Python 2 Roy Smith <roy@panix.com> - 2014-01-09 08:21 -0800
Re: the Gravity of Python 2 Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-01-09 16:30 +0000
Re: the Gravity of Python 2 Roy Smith <roy@panix.com> - 2014-01-09 09:07 -0800
Re: the Gravity of Python 2 Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-01-09 18:20 +0000
Re: the Gravity of Python 2 Ethan Furman <ethan@stoneleaf.us> - 2014-01-09 10:29 -0800
Re: the Gravity of Python 2 Tim Golden <mail@timgolden.me.uk> - 2014-01-09 16:41 +0000
RE: the Gravity of Python 2 Nick Cash <nick.cash@npcinternational.com> - 2014-01-09 16:42 +0000
Re: the Gravity of Python 2 Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-01-09 16:50 +0000
Re: the Gravity of Python 2 Chris Angelico <rosuav@gmail.com> - 2014-01-10 07:35 +1100
Re: the Gravity of Python 2 Roy Smith <roy@panix.com> - 2014-01-09 12:54 -0800
Re: the Gravity of Python 2 Chris Angelico <rosuav@gmail.com> - 2014-01-10 08:12 +1100
Re: the Gravity of Python 2 Dan Sommers <dan@tombstonezero.net> - 2014-01-09 15:01 +0000
Re: the Gravity of Python 2 Chris Angelico <rosuav@gmail.com> - 2014-01-10 02:17 +1100
Re: the Gravity of Python 2 Ethan Furman <ethan@stoneleaf.us> - 2014-01-09 07:56 -0800
Re: the Gravity of Python 2 Kushal Kumaran <kushal.kumaran@gmail.com> - 2014-01-09 11:36 +0530
Re: the Gravity of Python 2 Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-01-09 08:53 +0000
Re: the Gravity of Python 2 Ben Finney <ben+python@benfinney.id.au> - 2014-01-09 20:03 +1100
Re: the Gravity of Python 2 Kushal Kumaran <kushal.kumaran@gmail.com> - 2014-01-09 14:51 +0530
Re: the Gravity of Python 2 Piet van Oostrum <piet@vanoostrum.org> - 2014-01-09 12:26 +0100
Re: the Gravity of Python 2 Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-01-09 09:51 +0000
Re: the Gravity of Python 2 Ben Finney <ben+python@benfinney.id.au> - 2014-01-10 00:35 +1100
Re: the Gravity of Python 2 Roy Smith <roy@panix.com> - 2014-01-09 09:32 -0500
Re: the Gravity of Python 2 Ben Finney <ben+python@benfinney.id.au> - 2014-01-09 14:34 +1100
Re: the Gravity of Python 2 Roy Smith <roy@panix.com> - 2014-01-08 22:44 -0500
Re: the Gravity of Python 2 Chris Angelico <rosuav@gmail.com> - 2014-01-09 14:42 +1100
Re: the Gravity of Python 2 Piet van Oostrum <piet@vanoostrum.org> - 2014-01-09 15:06 +0100
Re: the Gravity of Python 2 Chris Angelico <rosuav@gmail.com> - 2014-01-10 01:34 +1100
Re: the Gravity of Python 2 Roy Smith <roy@panix.com> - 2014-01-09 09:44 -0500
Re: the Gravity of Python 2 Piet van Oostrum <piet@vanoostrum.org> - 2014-01-09 17:51 +0100
Re: the Gravity of Python 2 Chris Angelico <rosuav@gmail.com> - 2014-01-10 07:43 +1100
Time zones and why they change so damned often (was: the Gravity of Python 2) Ben Finney <ben+python@benfinney.id.au> - 2014-01-09 14:54 +1100
Re: Time zones and why they change so damned often (was: the Gravity of Python 2) Chris Angelico <rosuav@gmail.com> - 2014-01-09 15:14 +1100
Re: Time zones and why they change so damned often (was: the Gravity of Python 2) Peter Pearson <ppearson@nowhere.invalid> - 2014-01-10 18:22 +0000
Re: Time zones and why they change so damned often MRAB <python@mrabarnett.plus.com> - 2014-01-10 18:48 +0000
Re: Time zones and why they change so damned often Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-01-10 18:53 +0000
Re: Time zones and why they change so damned often Grant Edwards <invalid@invalid.invalid> - 2014-01-10 19:55 +0000
Re: Time zones and why they change so damned often Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2014-01-10 19:45 -0500
Re: Time zones and why they change so damned often Gene Heskett <gheskett@wdtv.com> - 2014-01-10 21:53 -0500
Re: Time zones and why they change so damned often (was: the Gravity of Python 2) Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2014-01-10 19:43 -0500
Re: Time zones and why they change so damned often (was: the Gravity of Python 2) Roy Smith <roy@panix.com> - 2014-01-10 19:49 -0500
Re: the Gravity of Python 2 Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-01-09 07:10 +0000
Re: Time zones and why they change so damned often Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-01-09 07:17 +0000
Re: Time zones and why they change so damned often Alister <alister.ware@ntlworld.com> - 2014-01-09 12:07 +0000
Re: Time zones and why they change so damned often Bob Martin <bob.martin@excite.com> - 2014-01-10 07:31 +0000
Re: Time zones and why they change so damned often Alister <alister.ware@ntlworld.com> - 2014-01-10 09:04 +0000
Re: Time zones and why they change so damned often Bob Martin <bob.martin@excite.com> - 2014-01-11 07:52 +0000
Re: Time zones and why they change so damned often Alister <alister.ware@ntlworld.com> - 2014-01-11 11:10 +0000
Re: Time zones and why they change so damned often Alister <alister.ware@ntlworld.com> - 2014-01-11 11:14 +0000
Re: Time zones and why they change so damned often Alister <alister.ware@ntlworld.com> - 2014-01-11 11:14 +0000
Re: Time zones and why they change so damned often (was: the Gravity
of Python 2) Dave Angel <davea@davea.name> - 2014-01-09 10:34 -0500
Re: the Gravity of Python 2 Ethan Furman <ethan@stoneleaf.us> - 2014-01-08 17:52 -0800
Re: the Gravity of Python 2 Chris Angelico <rosuav@gmail.com> - 2014-01-09 13:09 +1100
Re: the Gravity of Python 2 Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-01-09 08:42 +0000
Re: the Gravity of Python 2 Ethan Furman <ethan@stoneleaf.us> - 2014-01-09 08:01 -0800
Re: the Gravity of Python 2 Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-01-09 18:18 +0000
Re: the Gravity of Python 2 Ethan Furman <ethan@stoneleaf.us> - 2014-01-09 10:33 -0800
Re: the Gravity of Python 2 Pedro Larroy <pedro.larroy.lists@gmail.com> - 2014-01-08 15:45 +0100
Re: the Gravity of Python 2 Chris Angelico <rosuav@gmail.com> - 2014-01-09 01:50 +1100
Re: the Gravity of Python 2 Grant Edwards <invalid@invalid.invalid> - 2014-01-08 15:06 +0000
Re: the Gravity of Python 2 Chris Angelico <rosuav@gmail.com> - 2014-01-09 02:31 +1100
Re: the Gravity of Python 2 Terry Reedy <tjreedy@udel.edu> - 2014-01-08 15:45 -0500
Re: the Gravity of Python 2 Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-01-08 14:15 +0000
csiph-web