[issue12750] datetime.strftime('%s') should respect tzinfo

2016-07-15 Thread Alexander Belopolsky
Changes by Alexander Belopolsky : -- versions: +Python 3.6 -Python 3.5 ___ Python tracker ___

[issue12750] datetime.strftime('%s') should respect tzinfo

2016-07-15 Thread Alexander Belopolsky
Changes by Alexander Belopolsky : -- nosy: +shanmbic ___ Python tracker ___

[issue12750] datetime.strftime('%s') should respect tzinfo

2014-08-21 Thread Akira Li
Akira Li added the comment: issue22246 discusses the reverse: strptime('12345', '%s') -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12750 ___

[issue12750] datetime.strftime('%s') should respect tzinfo

2014-07-01 Thread Mümin Öztürk
Mümin Öztürk added the comment: more tests and some documentation added. -- Added file: http://bugs.python.org/file35816/strftime3.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12750

[issue12750] datetime.strftime('%s') should respect tzinfo

2014-07-01 Thread akira
akira added the comment: ``%s`` format code behaviour was undefined and incidental. strftime('%s') is not portable but it *is* supported on some platforms i.e., it is *not* undefined and it is *not* incidental on these platforms. datetime.strftime *delegates* to the platform strftime(3) and

[issue12750] datetime.strftime('%s') should respect tzinfo

2014-06-29 Thread akira
akira added the comment: Can you explain why math.floor rather than builtin round is the correct function to use? To avoid breaking existing scripts that use `.strftime('%s')` on Linux, OSX, see msg221385: from datetime import datetime, timezone dt = datetime(1969, 1, 1, 0,0,0,

[issue12750] datetime.strftime('%s') should respect tzinfo

2014-06-29 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: Here is the simpler demonstration of the floor behavior on Linux: from datetime import datetime datetime.fromtimestamp(-0.1).strftime('%s') '-1' datetime.fromtimestamp(-1.1).strftime('%s') '-2' datetime.fromtimestamp(0.1).strftime('%s') '0'

[issue12750] datetime.strftime('%s') should respect tzinfo

2014-06-29 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: Could you, please add tests for non-fixed offset timezones? There are several defined in datetimetester.py already. -- versions: +Python 3.5 -Python 3.3 ___ Python tracker rep...@bugs.python.org

[issue12750] datetime.strftime('%s') should respect tzinfo

2014-06-29 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: The patch should update documentation. See https://docs.python.org/3.5/library/datetime.html#strftime-and-strptime-behavior -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12750

[issue12750] datetime.strftime('%s') should respect tzinfo

2014-06-29 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: +t = datetime(1969, 1, 1, 0,0,0, 60, tzinfo=timezone.utc) Please add spaces after commas. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12750

[issue12750] datetime.strftime('%s') should respect tzinfo

2014-06-26 Thread akira
akira added the comment: I suspect that in the absence of %z, the most useful option would be to return naive datetime in the local timezone, but that can be added later. Naive datetime in the local timezone may lose information that is contained in the input timestamp: import os

[issue12750] datetime.strftime('%s') should respect tzinfo

2014-06-26 Thread Mümin Öztürk
Mümin Öztürk added the comment: I added an improved patch according to akira's explanation for strftime and rounding problem. -- Added file: http://bugs.python.org/file35785/strftime2.patch ___ Python tracker rep...@bugs.python.org

[issue12750] datetime.strftime('%s') should respect tzinfo

2014-06-26 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: On the second thought, I don't think accepting this should be contingent on any decision with respect to strptime. -- assignee: - belopolsky stage: needs patch - commit review ___ Python tracker

[issue12750] datetime.strftime('%s') should respect tzinfo

2014-06-26 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: rounding problem fixed with math.floor Can you explain why math.floor rather than builtin round is the correct function to use? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12750

[issue12750] datetime.strftime('%s') should respect tzinfo

2014-06-23 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: I would like to hear from others on this feature. One concern that I have is whether it is wise to truncate the fractional seconds part in '%s'. Also, if we support '%s' in strftime we should probably support it in strptime as well. -- nosy:

[issue12750] datetime.strftime('%s') should respect tzinfo

2014-06-23 Thread akira
akira added the comment: *If* the support for %s strftime format code is added then it should keep backward compatibility on Linux, OSX: it should produce an integer string with the correct rounding. Currently, datetime.strftime delegates to a platform strftime(3) for format specifiers that are

[issue12750] datetime.strftime('%s') should respect tzinfo

2014-06-23 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: It is not clear what the returned value for %s strptime should be: I would start conservatively and require %z to be used with %s. In this case, we can easily produce aware datetime objects. I suspect that in the absence of %z, the most useful option

[issue12750] datetime.strftime('%s') should respect tzinfo

2012-09-20 Thread Mümin Öztürk
Mümin Öztürk added the comment: I made a patch for datetime.strftime('%s'). it takes tzinfo into consideration. datetime.datetime(1970,1,1).strftime(%s) '-7200' datetime.datetime(1970,1,1, tzinfo=datetime.timezone.utc).strftime(%s) '0' datetime.date still behave as naive

[issue12750] datetime.strftime('%s') should respect tzinfo

2011-08-17 Thread Santoso Wijaya
Changes by Santoso Wijaya santoso.wij...@gmail.com: -- nosy: +santa4nt ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12750 ___ ___

[issue12750] datetime.strftime('%s') should respect tzinfo

2011-08-16 Thread Alexander Belopolsky
Alexander Belopolsky alexander.belopol...@gmail.com added the comment: it would appear the problem lies with strftime() Yes, strftime('%s') ignores tzinfo at the moment. This is not a bug. Support for '%s' format code is incidental and not documented in Python. Nevertheless I think this is

[issue12750] datetime.strftime('%s') should respect tzinfo

2011-08-16 Thread Daniel O'Connor
Daniel O'Connor dar...@dons.net.au added the comment: On 17/08/2011, at 12:42, Alexander Belopolsky wrote: Alexander Belopolsky alexander.belopol...@gmail.com added the comment: it would appear the problem lies with strftime() Yes, strftime('%s') ignores tzinfo at the moment. This is not