[issue19475] Add timespec optional flag to datetime isoformat() to choose the precision

2016-03-06 Thread Roundup Robot
Roundup Robot added the comment: New changeset eb120f50df4a by Alexander Belopolsky in branch 'default': Closes #19475: Added timespec to the datetime.isoformat() method. https://hg.python.org/cpython/rev/eb120f50df4a -- nosy: +python-dev resolution: -> fixed stage: commit review ->

[issue19475] Add timespec optional flag to datetime isoformat() to choose the precision

2016-03-02 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: Alessandro, thank you very much for your work and perseverance. I will do my best to commit this next weekend. -- stage: patch review -> commit review ___ Python tracker

[issue19475] Add timespec optional flag to datetime isoformat() to choose the precision

2016-03-02 Thread SilentGhost
Changes by SilentGhost : -- nosy: -SilentGhost ___ Python tracker ___ ___

[issue19475] Add timespec optional flag to datetime isoformat() to choose the precision

2016-03-02 Thread Alessandro Cucci
Alessandro Cucci added the comment: Meanwhile I made corrections after @belopolsky latest review -- Added file: http://bugs.python.org/file42063/issue19475_v17.patch ___ Python tracker

[issue19475] Add timespec optional flag to datetime isoformat() to choose the precision

2016-03-01 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: I feel odd trying to advocate a POV that I disagree with, so let me just quote MAL: """ In practice you often don't know the resolution of the timing source. Nowadays, the reverse of what you said is usually true: the source resolution is higher than

[issue19475] Add timespec optional flag to datetime isoformat() to choose the precision

2016-03-01 Thread STINNER Victor
STINNER Victor added the comment: > Personally, I don't rounding is that useful. Nice, it looks like I agree with you on using ROUNDING_FLOOR :-) I don't think that we should be prepared for theorical user requests, but rather focus on the concrete and well defined current existing user

[issue19475] Add timespec optional flag to datetime isoformat() to choose the precision

2016-03-01 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: Personally, I don't rounding is that useful. My working assumption is that users will select say timespec='millisecond' only when they know that their time source produces datetime instances with millisecond precision and they don't want to kill more

[issue19475] Add timespec optional flag to datetime isoformat() to choose the precision

2016-03-01 Thread STINNER Victor
STINNER Victor added the comment: > Maybe a datetime.round() method along these lines will be a worthwhile > addition? Sorry, what is the use case of this method? -- ___ Python tracker

[issue19475] Add timespec optional flag to datetime isoformat() to choose the precision

2016-03-01 Thread Guido van Rossum
Guido van Rossum added the comment: IIUC truncation traditionally means "towards zero" -- that's why we have separate "floor" and "ceiling" operations meaning "towards [negative] infinity". Fortunately we shouldn't have to deal with negative values here so floor and truncate mean the same

[issue19475] Add timespec optional flag to datetime isoformat() to choose the precision

2016-03-01 Thread Guido van Rossum
Guido van Rossum added the comment: Except for the case where you're closer than half a usec from the next value, IMO rounding makes no sense when suppressing digits. I most definitely would never want 9:59:59 to be rounded to 10:00 when suppressing seconds. If you really think there are use

[issue19475] Add timespec optional flag to datetime isoformat() to choose the precision

2016-03-01 Thread STINNER Victor
STINNER Victor added the comment: > But what should we do in your opinion? Use ROUND_FLOOR rounding method. time.time(), datetime.datetime.now(), etc. round the current time using the ROUND_FLOOR rounding method. Only datetime.datetime.fromtimestamp() uses ROUND_HALF_EVEN, but it's more an

[issue19475] Add timespec optional flag to datetime isoformat() to choose the precision

2016-03-01 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: I hope my prediction "I am afraid that the rounding issues may kill this proposal" (see msg202276) will not come true. I think the correct way to view "timespec" is a way to suppress/enforce printing of trailing digits. Users that choose printing less

[issue19475] Add timespec optional flag to datetime isoformat() to choose the precision

2016-03-01 Thread Guido van Rossum
Guido van Rossum added the comment: But what should we do in your opinion? -- ___ Python tracker ___ ___

[issue19475] Add timespec optional flag to datetime isoformat() to choose the precision

2016-03-01 Thread STINNER Victor
STINNER Victor added the comment: > Given that we're talking about what to do when we're suppressing the usecs I > don't think roundtripping matters. :-) I changed many times how Python rounds nanoseconds in the private PyTime API, and I got a bug report because of that! => issue #23517. By

[issue19475] Add timespec optional flag to datetime isoformat() to choose the precision

2016-03-01 Thread Guido van Rossum
Guido van Rossum added the comment: Given that we're talking about what to do when we're suppressing the usecs I don't think roundtripping matters. :-) -- ___ Python tracker

[issue19475] Add timespec optional flag to datetime isoformat() to choose the precision

2016-03-01 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: Another argument for truncation is that this is what GNU date does: $ date --iso-8601=seconds --date="2016-03-01 15:00:00.999" 2016-03-01T15:00:00-0500 -- ___ Python tracker

[issue19475] Add timespec optional flag to datetime isoformat() to choose the precision

2016-03-01 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: Guido, Did you consider MAL's msg202274? I am still in favor of truncation, but would like to make sure we are not missing something that MAL knows from experience. -- ___ Python tracker

[issue19475] Add timespec optional flag to datetime isoformat() to choose the precision

2016-03-01 Thread Alexander Belopolsky
Changes by Alexander Belopolsky : -- stage: needs patch -> patch review ___ Python tracker ___

[issue19475] Add timespec optional flag to datetime isoformat() to choose the precision

2016-02-25 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: We discussed truncation vs. rounding some time ago. See msg202270 and the posts around it. The consensus was the same as Guido's current advise: do the truncation. -- ___ Python tracker

[issue19475] Add timespec optional flag to datetime isoformat() to choose the precision

2016-02-25 Thread Guido van Rossum
Guido van Rossum added the comment: Out of context here, but regarding round vs. truncate, IIUC for time truncating down is the norm. My digital clock shows "12:00" for the duration of the minute starting at noon. People look for clocks to flip to know when it is exactly a given time (if the

[issue19475] Add timespec optional flag to datetime isoformat() to choose the precision

2016-02-25 Thread Alessandro Cucci
Alessandro Cucci added the comment: Oh, now I see your point. I've uploaded a new patch with a note for that. -- Added file: http://bugs.python.org/file42031/issue19475_v16.patch ___ Python tracker

[issue19475] Add timespec optional flag to datetime isoformat() to choose the precision

2016-02-23 Thread Martin Panter
Martin Panter added the comment: About rounding: I’m not too sure what people would expect. Obviously it is much easier to implement truncating to zero. But it is different to many other rounding cases in Python; that is why I thought to make it explicit. >>>

[issue19475] Add timespec optional flag to datetime isoformat() to choose the precision

2016-02-22 Thread Alessandro Cucci
Alessandro Cucci added the comment: New patch after @martin.panter comments on Rietveld. I left only this: - ``'milliseconds'``: Append the hours, minutes, seconds and milliseconds. > vadmium 2016/02/21 23:30:20 > I think this should explain that fractions are truncated to zero, never >

[issue19475] Add timespec optional flag to datetime isoformat() to choose the precision

2016-02-22 Thread Andrei Dorian Duma
Changes by Andrei Dorian Duma : -- nosy: -andrei.duma ___ Python tracker ___

[issue19475] Add timespec optional flag to datetime isoformat() to choose the precision

2016-02-21 Thread Martin Panter
Martin Panter added the comment: Left some review suggestions -- ___ Python tracker ___ ___ Python-bugs-list

[issue19475] Add timespec optional flag to datetime isoformat() to choose the precision

2016-02-21 Thread Alessandro Cucci
Alessandro Cucci added the comment: New patch -- Added file: http://bugs.python.org/file41988/issue19475_v13.patch ___ Python tracker ___

[issue19475] Add timespec optional flag to datetime isoformat() to choose the precision

2016-01-17 Thread Guido van Rossum
Guido van Rossum added the comment: I think Alexander has commit rights, he did most of the review, I trust him to commit it. -- ___ Python tracker ___

[issue19475] Add timespec optional flag to datetime isoformat() to choose the precision

2016-01-17 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: I left some comments on Rietveld. -- stage: commit review -> needs patch ___ Python tracker ___

[issue19475] Add timespec optional flag to datetime isoformat() to choose the precision

2016-01-17 Thread Alexander Belopolsky
Changes by Alexander Belopolsky : -- assignee: -> belopolsky stage: patch review -> commit review ___ Python tracker ___

[issue19475] Add timespec optional flag to datetime isoformat() to choose the precision

2016-01-17 Thread SilentGhost
SilentGhost added the comment: Yes, version 12 is the final patch. It doesn't add those options. To copy my opinion from the rietveld (https://bugs.python.org/review/19475/#msg14): > I don't really think nanoseconds belong here. If they don't > exist anywhere else in the module, why should

[issue19475] Add timespec optional flag to datetime isoformat() to choose the precision

2016-01-17 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: > I don't really think nanoseconds belong here. What about milliseconds? I'll leave it for Guido to make a call on nanoseconds. My vote is +0.5. > If they don't > exist anywhere else in the module, why should they be suddenly > introduced here? The

[issue19475] Add timespec optional flag to datetime isoformat() to choose the precision

2016-01-17 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: Is issue19475_v12.patch the final patch? I don't see it addressing Guido's suggestion in msg256470 to add milli- and nanoseconds options. -- ___ Python tracker

[issue19475] Add timespec optional flag to datetime isoformat() to choose the precision

2016-01-17 Thread Guido van Rossum
Guido van Rossum added the comment: You can leave out the nanoseconds but please do add the milliseconds. I'm sure they would find more use than the option to show only the hours. -- ___ Python tracker

[issue19475] Add timespec optional flag to datetime isoformat() to choose the precision

2016-01-17 Thread SilentGhost
SilentGhost added the comment: > I there anything else I can do for this? I think you've done all you could, it's just someone needs to commit it. I don't think they're being rude on purpose - it's just that there are so many committers in the nosy list that no one is feeling like it's their

[issue19475] Add timespec optional flag to datetime isoformat() to choose the precision

2016-01-15 Thread Alessandro Cucci
Alessandro Cucci added the comment: I there anything else I can do for this? -- ___ Python tracker ___ ___

[issue19475] Add timespec optional flag to datetime isoformat() to choose the precision

2016-01-15 Thread R. David Murray
Changes by R. David Murray : -- nosy: -r.david.murray ___ Python tracker ___ ___

[issue19475] Add timespec optional flag to datetime isoformat() to choose the precision

2016-01-05 Thread Alessandro Cucci
Alessandro Cucci added the comment: up -- ___ Python tracker ___ ___ Python-bugs-list mailing list

[issue19475] Add timespec optional flag to datetime isoformat() to choose the precision

2016-01-01 Thread Martin Panter
Martin Panter added the comment: I think there is a memory leak in the C code. I left some other minor suggestions as well, but it almost looks ready. -- ___ Python tracker

[issue19475] Add timespec optional flag to datetime isoformat() to choose the precision

2016-01-01 Thread Alessandro Cucci
Alessandro Cucci added the comment: Thanks @martin.panter, here is another patch made after your comments. -- Added file: http://bugs.python.org/file41464/issue19475_v12.patch ___ Python tracker

[issue19475] Add timespec optional flag to datetime isoformat() to choose the precision

2015-12-29 Thread SilentGhost
Changes by SilentGhost : -- stage: patch review -> commit review ___ Python tracker ___

[issue19475] Add timespec optional flag to datetime isoformat() to choose the precision

2015-12-29 Thread Berker Peksag
Berker Peksag added the comment: Thanks for the patch, Alessandro. I left some comments about documentation part of the patch, but I can fix them myself if you don't have time. -- stage: commit review -> patch review ___ Python tracker

[issue19475] Add timespec optional flag to datetime isoformat() to choose the precision

2015-12-29 Thread Alessandro Cucci
Alessandro Cucci added the comment: Berker, thank you. In the last patch, I removed details about timespec options in Python and C docstrings, corrected the rst quotes, and checked PEP7 in the c file. The only problem now is about versionchanged vs versionadded. I leave it as it was, as

[issue19475] Add timespec optional flag to datetime isoformat() to choose the precision

2015-12-29 Thread Alessandro Cucci
Alessandro Cucci added the comment: what about the comment left by SilentGhost about versionadded? -- ___ Python tracker ___

[issue19475] Add timespec optional flag to datetime isoformat() to choose the precision

2015-12-25 Thread Alessandro Cucci
Alessandro Cucci added the comment: > I think timespec= option should also be added to the time.isoformat method. @belopolsky I've done it in my last patch. -- Added file: http://bugs.python.org/file41420/issue19475_v10_datetime_time.patch ___

[issue19475] Add timespec optional flag to datetime isoformat() to choose the precision

2015-12-23 Thread Skip Montanaro
Changes by Skip Montanaro : -- nosy: -skip.montanaro ___ Python tracker ___ ___

[issue19475] Add timespec optional flag to datetime isoformat() to choose the precision

2015-12-22 Thread Alessandro Cucci
Alessandro Cucci added the comment: Thanks SilentGhost! -- Added file: http://bugs.python.org/file41391/issue19475_v9.patch ___ Python tracker ___

[issue19475] Add timespec optional flag to datetime isoformat() to choose the precision

2015-12-22 Thread Alessandro Cucci
Alessandro Cucci added the comment: Sorry @SilentGhost, I didn't seen your comment at the bottom of the review. With this patch is microsecond is 0, the time will display 6 zeroes. -- Added file: http://bugs.python.org/file41388/issue19475_v8.patch

[issue19475] Add timespec optional flag to datetime isoformat() to choose the precision

2015-12-22 Thread Alessandro Cucci
Changes by Alessandro Cucci : Added file: http://bugs.python.org/file41387/issue19475_v7.patch ___ Python tracker ___

[issue19475] Add timespec optional flag to datetime isoformat() to choose the precision

2015-12-22 Thread SilentGhost
SilentGhost added the comment: I think the patch is nearly finalised, but I'd appreciate if someone else would carefully go over the new C code. After that, I think, the patch could be committed. -- ___ Python tracker

[issue19475] Add timespec optional flag to datetime isoformat() to choose the precision

2015-12-21 Thread Alessandro Cucci
Alessandro Cucci added the comment: Uploaded a new patch after SilentGhost review comments. As he told me, I've left out milliseconds and nanoseconds, but refactored both python and c code so we could easily add support for them when they will be available. -- Added file:

[issue19475] Add timespec optional flag to datetime isoformat() to choose the precision

2015-12-20 Thread Alessandro Cucci
Alessandro Cucci added the comment: Uploaded a new patch. This time I ran tests using: $ ./python -m test -v test_datetime and got no errors. I've written the c docstring, updated docs, and rewrote _format_time function. I know it's boring review this another time, but I'm doing my best.

[issue19475] Add timespec optional flag to datetime isoformat() to choose the precision

2015-12-17 Thread Martin Panter
Martin Panter added the comment: If the timespec allowed any arbitrary number of digits after the decimal point, that would remove any argument about nanoseconds not being supported. It would also mean I could use this in one case where I currently format to two decimal places (my compromise

[issue19475] Add timespec optional flag to datetime isoformat() to choose the precision

2015-12-16 Thread SilentGhost
Changes by SilentGhost : -- nosy: +SilentGhost ___ Python tracker ___ ___

[issue19475] Add timespec optional flag to datetime isoformat() to choose the precision

2015-12-16 Thread Martin Panter
Martin Panter added the comment: With patch v4 many tests still fail for me. How are you running the test suite? Some excerpts: File "/media/disk/home/proj/python/cpython/Lib/test/datetimetester.py", line 1567, in test_isoformat self.assertEqual(t.isoformat(timespec='milliseconds'),

[issue19475] Add timespec optional flag to datetime isoformat() to choose the precision

2015-12-16 Thread SilentGhost
SilentGhost added the comment: Even that produces 3 failures on my setup, though the full list would be available when running: ./python -m test -v test_datetime It is obvious, however, that the tests would fail: you've changed "if us:" to "if us is None:". --

[issue19475] Add timespec optional flag to datetime isoformat() to choose the precision

2015-12-16 Thread Alessandro Cucci
Alessandro Cucci added the comment: Uploaded a new patch (v4): DONE: - now all tests work (I also added one more) - removed non ascii chars - added milliseconds and nanoseconds as multiple of microseconds - removed code duplication in the datetime.py - update the docstring. TODO: > The doc

[issue19475] Add timespec optional flag to datetime isoformat() to choose the precision

2015-12-16 Thread Alessandro Cucci
Alessandro Cucci added the comment: I just did that... ~/Documenti/cpython$ ./configure --with-pydebug ~/Documenti/cpython$ make -s -j2 ~/Documenti/cpython$ ./python -m test -v datetimetester ... ... -- Ran 325 tests in 1.128s

[issue19475] Add timespec optional flag to datetime isoformat() to choose the precision

2015-12-15 Thread Guido van Rossum
Guido van Rossum added the comment: I like the idea. I have one suggestion: can we add 'milliseconds' as an option too? And might a well add 'nanoseconds' too, for future-proofing. I suppose there isn't a real use case for 'hours' but it seems silly to leave it out. I expect that 'minutes'

[issue19475] Add timespec optional flag to datetime isoformat() to choose the precision

2015-12-15 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: It looks like issue19475_v3.patch uses some fancy Unicode quotes in the docstrings and .rst docs. Please change them to ASCII. -- ___ Python tracker

[issue19475] Add timespec optional flag to datetime isoformat() to choose the precision

2015-12-15 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: GvR> I suppose there isn't a real use case for 'hours' but it seems silly to leave it out. Shouldn't we also have 'none' to leave out the time component entirely? -- ___ Python tracker

[issue19475] Add timespec optional flag to datetime isoformat() to choose the precision

2015-12-15 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: > The problem here is that millisecond and nanosecond seems not to be > attributes of the datetime object. millisecond = dt.microsecond // 1000 nanosecond = 0 # until we add it to datetime. -- ___ Python

[issue19475] Add timespec optional flag to datetime isoformat() to choose the precision

2015-12-15 Thread Guido van Rossum
Guido van Rossum added the comment: Actually, nanosecond = dt.microsecond*1000. I don't think we need 'none' -- you should just extract the date component and call its isoformat() method if that's what you want. On Tue, Dec 15, 2015 at 12:01 PM, Alexander Belopolsky < rep...@bugs.python.org>

[issue19475] Add timespec optional flag to datetime isoformat() to choose the precision

2015-12-15 Thread Alessandro Cucci
Alessandro Cucci added the comment: I can work on that, although I'll need help from some senior dev. The problem here is that millisecond and nanosecond seems not to be attributes of the datetime object. What about open a new issue if we have to add them? Is not about adding an optional flag

[issue19475] Add timespec optional flag to datetime isoformat() to choose the precision

2015-12-15 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: > Actually, nanosecond = dt.microsecond*1000. I was thinking in terms breaking the fractional part of say 00:00:00.123456789 into mili = 123 micro = 456 nano = 789 but you are right, a correct analogy for dt.microsecond in this case will be

[issue19475] Add timespec optional flag to datetime isoformat() to choose the precision

2015-12-15 Thread Martin Panter
Martin Panter added the comment: Alessandro, did you try running the test suite? It is broken for me. One of the bugs is that it now omits zero hours, minutes, and seconds in addition to microseconds. (Kind of the reverse of what the bug was originally about :). Other failures look like this:

[issue19475] Add timespec optional flag to datetime isoformat() to choose the precision

2015-12-15 Thread Martin Panter
Martin Panter added the comment: The doc string in the C module needs updating. -- ___ Python tracker ___ ___

[issue19475] Add timespec optional flag to datetime isoformat() to choose the precision

2015-12-15 Thread Alessandro Cucci
Alessandro Cucci added the comment: Please can I have an update on this? It's already 4 months old, I'd like to see it closed. :) -- ___ Python tracker

[issue19475] Add timespec optional flag to datetime isoformat() to choose the precision

2015-12-15 Thread STINNER Victor
Changes by STINNER Victor : -- nosy: +matrixise ___ Python tracker ___ ___

[issue19475] Add timespec optional flag to datetime isoformat() to choose the precision

2015-12-15 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: I think timespec= option should also be added to the time.isoformat method. -- ___ Python tracker ___

[issue19475] Add timespec optional flag to datetime isoformat() to choose the precision

2015-12-15 Thread Alessandro Cucci
Alessandro Cucci added the comment: Thanks for all the comments, here and on Rietveld. I'll keep working on it. Hope to upload a new patch soon. -- ___ Python tracker

[issue19475] Add timespec optional flag to datetime isoformat() to choose the precision

2015-08-03 Thread Alessandro Cucci
Alessandro Cucci added the comment: uploaded a new patch! -- Added file: http://bugs.python.org/file40117/issue19475_v3.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue19475 ___

[issue19475] Add timespec optional flag to datetime isoformat() to choose the precision

2015-07-30 Thread Berker Peksag
Berker Peksag added the comment: Thanks, Alessandro! I left some additional comments on Rietveld: https://bugs.python.org/review/19475/#ps15278 -- nosy: +berker.peksag stage: needs patch - patch review ___ Python tracker rep...@bugs.python.org

[issue19475] Add timespec optional flag to datetime isoformat() to choose the precision

2015-07-26 Thread Alessandro Cucci
Alessandro Cucci added the comment: udloaded a new patch, hope i had all bugs fixed! -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue19475 ___

[issue19475] Add timespec optional flag to datetime isoformat() to choose the precision

2015-07-25 Thread Alessandro Cucci
Changes by Alessandro Cucci alessandro.cu...@gmail.com: -- keywords: +patch Added file: http://bugs.python.org/file40018/issue19475.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue19475

[issue19475] Add timespec optional flag to datetime isoformat() to choose the precision

2015-07-25 Thread STINNER Victor
STINNER Victor added the comment: @acucci: Nice first try, but your patch contains multiple bugs. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue19475 ___

[issue19475] Add timespec optional flag to datetime isoformat() to choose the precision

2015-07-25 Thread Alessandro Cucci
Alessandro Cucci added the comment: @haypo thanks for the review and the suggestions, I'll correct the code soon -- nosy: +acucci ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue19475 ___

[issue19475] Add timespec optional flag to datetime isoformat() to choose the precision

2015-07-25 Thread Alessandro Cucci
Changes by Alessandro Cucci alessandro.cu...@gmail.com: Added file: http://bugs.python.org/file40024/issue19475_v2.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue19475 ___

[issue19475] Add timespec optional flag to datetime isoformat() to choose the precision

2015-07-24 Thread STINNER Victor
Changes by STINNER Victor victor.stin...@gmail.com: -- title: Add microsecond flag to datetime isoformat() - Add timespec optional flag to datetime isoformat() to choose the precision ___ Python tracker rep...@bugs.python.org