Alexander Belopolsky <alexander.belopol...@gmail.com> added the comment:
On Fri, Dec 17, 2010 at 9:18 AM, R. David Murray <rep...@bugs.python.org> wrote: > > R. David Murray <rdmur...@bitdance.com> added the comment: > > Alexander, I agree with Velko in that it isn't obvious to me how the addition > of localtime > would answer the desire expressed in this issue. Conversion of UTC datetime to time stamp is trivial: EPOCH = datetime(1970, 1, 1) def timestamp(t): return (t - EPOCH).total_seconds() There are several reasons not to include this one-liner in stdlib (other than it being a one-liner). 1. Different application may need different epoch and retained precision depends on the choice of the epoch. 2. The code above works only on naive datetime objects assumed to be in UTC. Passing say a result of datetime.now() to it is likely to result in a hard to find bug. 3. While it is not hard to extend the timestamp(t) code to cover aware datetime objects that use fixed offset tzinfo such as those with tzinfo set to a datetime.timezone instance, it is not well defined for the "smart" tzinfo implementations that do automatic DST adjustment. This is where the localtime (#9527) issue comes into play. ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue2736> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com