[issue1982] Feature: extend strftime to accept milliseconds
R. David Murray rdmur...@bitdance.com added the comment: You are better off opening a new issue as a feature request. Do add at least belopolsky as nosy on the new issue. -- nosy: +r.david.murray ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue1982 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1982] Feature: extend strftime to accept milliseconds
Ben magicbad...@gmail.com added the comment: Sorry to chime in on an old issue. Whilst it is good to have the ability to format the string up to microsecond precision, it would be better to be able to control the precision used. For instance, the ISO8601 specification states that there is no strictly defined precision to be used, and that any such precision should be agreed between parties exchanging ISO8601 datetimes. Would it be possible to state the precision when formatting ISO8601 datetimes - e.g. %3f to only print up to millisecond precision? presumable %f would keep the original functionality of printing right up to the microseconds. -- nosy: +magicbadger ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue1982 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1982] Feature: extend strftime to accept milliseconds
Thomas Guettler guet...@thomas-guettler.de added the comment: Yes, I think this can be closed, too. -- nosy: +guettli ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue1982 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1982] Feature: extend strftime to accept milliseconds
Changes by Alexander Belopolsky belopol...@users.sourceforge.net: -- resolution: - out of date stage: unit test needed - committed/rejected status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue1982 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1982] Feature: extend strftime to accept milliseconds
Changes by Giampaolo Rodola' g.rod...@gmail.com: -- nosy: +giampaolo.rodola ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue1982 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1982] Feature: extend strftime to accept milliseconds
Alexander Belopolsky belopol...@users.sourceforge.net added the comment: With %f support in, isn't this issue out of date? -- assignee: - belopolsky nosy: +belopolsky stage: - unit test needed versions: +Python 3.2 -Python 2.6 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue1982 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1982] Feature: extend strftime to accept milliseconds
Andreas Balogh balo...@gmail.com added the comment: - a_datetime.replace(microsecond = 1) + a_datetime = a_datetime.replace(microsecond = 1) Thanks for spotting the bug. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue1982 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1982] Feature: extend strftime to accept milliseconds
M. Dietrich m...@pyneo.org added the comment: i am not shure what the code snippet shall proove but shouldnt't it read from datetime import datetime a_datetime = datetime.now() a_datetime = a_datetime.replace(microsecond = 1) iso_str = a_datetime.isoformat() b_datetime = datetime.strptime(iso_str, %Y-%m-%dT%H:%M:%S.%f) assert(a_datetime == b_datetime) ? i general i would expect for each operation a reverse if possible to be complete. so if there is a strftime, i look for a strptime, if there is a isoformat, i like a isoparse. and to be complete i need a format tag for ms if there is a microseconds member in datatime object. -- nosy: +mdt ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue1982 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1982] Feature: extend strftime to accept milliseconds
Ziga Seilnacht [EMAIL PROTECTED] added the comment: Do you require millisecond support or would microsecond support be enough? r61402, which is included in Python 2.6, added support for %f format to datetime.strftime() and datetime.strptime(). See also #1158. -- nosy: +zseil ___ Python tracker [EMAIL PROTECTED] http://bugs.python.org/issue1982 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1982] Feature: extend strftime to accept milliseconds
Andreas Balogh [EMAIL PROTECTED] added the comment: Yes, microsecond support is fine. Elaborating on my initial comment. The following should assert: a_datetime = datetime.now() a_datetime.replace(microsecond = 1) iso_str = adatetime.isoformat() b_datetime = datetime.strptime(iso_str, %Y%m%dT%H%M%S.%f) assert(a_datetime = b_datetime) The datetime shall be an invariant. Fixed from my point of view, Andreas ___ Python tracker [EMAIL PROTECTED] http://bugs.python.org/issue1982 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1982] Feature: extend strftime to accept milliseconds
Andreas Balogh [EMAIL PROTECTED] added the comment: Some typos corrected. Sorry for any inconvenience. a_datetime = datetime.now() a_datetime.replace(microsecond = 1) iso_str = a_datetime.isoformat() b_datetime = datetime.strptime(iso_str, %Y-%m-%dT%H:%M:%S.%f) assert(a_datetime = b_datetime) ___ Python tracker [EMAIL PROTECTED] http://bugs.python.org/issue1982 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1982] Feature: extend strftime to accept milliseconds
Wang Chun [EMAIL PROTECTED] added the comment: Ruby recently added support of millisecond and nanosecond to strftime. This is their changeset: http://redmine.ruby-lang.org/repositories/revision/ruby-19?rev=18731 To use the extended strftime, one can do: Time.now.strftime('%Y-%m-%dT%H:%M:%S.%L%z') .. 2008-10-29T17:46:03.895+0800 In the current implementation of Python, both datetime and time modules have strftime. Like in Ruby, the strftime in datetime module is a method. But the strftime in time module is a function, which takes time value to be formatted from argument, and which must be a 9-tuple returned by gmtime or localtime. No microsecond data in the tuple, unfortunately. I think as the first step we can make datetime.datetime.strftime do microsecond. I prefer microsecond to milli- or micro- second because it is something from the the system. The current Ruby implementation use %L or %3N for millisecond, %6N for microsecond, and %N or %9N for nanosecond. I am not sure where they came from. Hope there can be some widely accepted standard. -- nosy: +wangchun ___ Python tracker [EMAIL PROTECTED] http://bugs.python.org/issue1982 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1982] Feature: extend strftime to accept milliseconds
Changes by Brett Cannon: -- type: - rfe __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1982 __ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1982] Feature: extend strftime to accept milliseconds
New submission from Andreas Balogh: Currently serializing datetime objects into isoformat string is well possible. The reverse process - parsing an isoformat string into a datetime object - doesn't work due to the missing %-tag for the strftime format string. Proposal: Add new tag to strftime like format strings allowing to print and parse milliseconds. -- components: Extension Modules messages: 61924 nosy: asbalogh severity: normal status: open title: Feature: extend strftime to accept milliseconds versions: Python 2.5 __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1982 __ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1982] Feature: extend strftime to accept milliseconds
Christian Heimes added the comment: Your chances are going to increase if you can come up with a decent patch. It's going to be harder than you might think. Python uses the system's strftime function. You'd have to implement a strftime replacement which supports miliseconds. Can't you use another like TAI64 (http://cr.yp.to/libtai/tai64.html#tai64n) or JDN (http://en.wikipedia.org/wiki/Julian_day) instead? -- nosy: +tiran priority: - normal versions: +Python 2.6 -Python 2.5 __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1982 __ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com