datetime question

Alister alister.ware at ntlworld.com
Tue Nov 12 11:11:16 EST 2013


On Tue, 12 Nov 2013 09:54:44 -0600, Tim Chase wrote:

> On 2013-11-12 17:24, Ferrous Cranus wrote:
>> But what of the server was in California and i live in Greece?
>> 
>> How would datetime.now() work then?
> 
> Best practices say to move the value from local time to UTC as soon as
> possible, then store/use the UTC time internally for all operations. 
> Only when it's about to be presented to the user should you convert it
> back to local time if you need to.
> 
> -tkc

& it is probably best converted to local time client side (as has already 
been suggested) you may end up with a situation where the server is in 
the USA & your user is in Portugal.
how i you going to identify the users time zone server side(clue you cant 
at least not reliably).

whatever solution you take it is better written as a function rather than 
a single line of code so it can be re-used, you are almost certainly 
going to want this in more than one place


complicated one-liners may "look cool" to show of your programming skills 
but in the real world they are a maintenance nightmare & are probably 
best avoided.


-- 
The plot was designed in a light vein that somehow became varicose.
		-- David Lardner



More information about the Python-list mailing list