the Gravity of Python 2

Mark Lawrence breamoreboy at yahoo.co.uk
Thu Jan 9 04:51:40 EST 2014


On 09/01/2014 09:03, Ben Finney wrote:
> Kushal Kumaran <kushal.kumaran at gmail.com> writes:
>
>> Roy Smith <roy at panix.com> writes:
>>> How, in Python, do you get an aware UTC datetime object?
>>
>> 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.
>
> No, that won't do what was asked. The ‘datetime.datetime.utcnow’
> function explicitly returns a naive datetime object, not an aware
> datetime object.
>

How closely do you bother to read posts that people like Kushal Kumaran 
have taken the trouble to post?  Eleven lines above this one it says (my 
emphasis) "An *AWARE* current UTC datetime can be obtained by
calling datetime.now(timezone.utc)".

-- 
My fellow Pythonistas, ask not what our language can do for you, ask 
what you can do for our language.

Mark Lawrence




More information about the Python-list mailing list