Issue2166

classification
Title: datetime.strptime does not support %f on Jython 2.7
Type: behaviour Severity: normal
Components: Versions: Jython 2.7
Milestone:
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: jeff.allen, pekka.klarck, santa4nt, zyasoft
Priority: Keywords:

Created on 2014-06-16.14:05:36 by pekka.klarck, last changed 2015-02-18.18:11:45 by zyasoft.

Messages
msg8650 (view) Author: Pekka Klärck (pekka.klarck) Date: 2014-06-16.14:05:35
Support for %f (microseconds) directive was added in Python 2.6. On Jython 2.7 beta 2 it seems to be supported with datetime.strftime, but with datetime.strptime microseconds are silently ignored.

Jython 2.7b2 (default:a5bc0032cf79+, Apr 22 2014, 21:20:17) 
[Java HotSpot(TM) 64-Bit Server VM (Oracle Corporation)] on java1.7.0_55
Type "help", "copyright", "credits" or "license" for more information.
>>> from datetime import datetime
>>> datetime.now().strftime('%Y-%m-%d %H:%M:%S.%f')
'2014-06-16 17:03:58.483000'
>>> datetime.strptime('2014-06-16 17:03:58.483000', '%Y-%m-%d %H:%M:%S.%f')
datetime.datetime(2014, 6, 16, 17, 3, 58)
msg8911 (view) Author: Santoso Wijaya (santa4nt) Date: 2014-08-11.16:04:40
I think this was fixed along with issue 2112.
msg8912 (view) Author: Jeff Allen (jeff.allen) Date: 2014-08-11.21:17:31
It's easily tested.
>>> from datetime import datetime
>>> fmt = '%Y-%m-%d %H:%M:%S.%f'
>>> t = datetime.now(); s = datetime.strptime(t.strftime(fmt), fmt); t-s
datetime.timedelta(0, 0, 476999)
>>> t.strftime(fmt)
'2014-08-11 21:20:33.476999'

With CPython I get:
>>> t = datetime.now(); s = datetime.strptime(t.strftime(fmt), fmt); t-s
datetime.timedelta(0)

Although it surprises me in that case that test_strptime passes (without skips).
msg8913 (view) Author: Jeff Allen (jeff.allen) Date: 2014-08-11.21:59:05
Note:  https://github.com/jythontools/jython/pull/7 (from PyCon AU, not me!)
msg9518 (view) Author: Jim Baker (zyasoft) Date: 2015-02-13.17:53:10
Fixed as of https://hg.python.org/jython/rev/daa6bf9a14d5
History
Date User Action Args
2015-02-18 18:11:45zyasoftsetstatus: pending -> closed
2015-02-13 17:53:10zyasoftsetstatus: open -> pending
resolution: fixed
messages: + msg9518
2014-08-11 21:59:05jeff.allensetmessages: + msg8913
2014-08-11 21:17:31jeff.allensetnosy: + jeff.allen
messages: + msg8912
2014-08-11 16:04:41santa4ntsettype: behaviour
messages: + msg8911
nosy: + santa4nt
2014-07-11 16:21:02zyasoftsetnosy: + zyasoft
2014-06-16 14:05:36pekka.klarckcreate