issue 2166 - datetime.strptime does not support %f on Jython 2.7

Anthony Kong <[email protected]>
Newsgroups gmane.comp.lang.jython.devel
Message-ID <CAAyd8c=czLBeS=5TohoDa4vDWTTBFdKZuVZeQZJVE+anuGc5ew@mail.gmail.com>
Hi all,

I would like to make some contribution to the jython project. I browsed the
bug tracker and randomly picked this issue as a  starting point:
http://bugs.jython.org/issue2166

I think this is the cause of the bug:


In src/org/python/modules/time/Time.java, function 'private static PyTuple
pystrptime(String data_string, String format)' , it calls
_strptime._strptime_time to parse the data_string according to the format.
But this function does not understand '%f' flag.



 >>> from _strptime import _strptime_time

>>> _strptime_time('2014-06-16 17:03:58.483000', '%Y-%m-%d %H:%M:%S.%f')

time.struct_time(tm_year=2014, tm_mon=6, tm_mday=16, tm_hour=17, tm_min=3,
tm_sec=58, tm_wday=0, tm_yday=167, tm_isdst=-1)


If we call _strptime instead, we will get this result instead:

>>> from _strptime import _strptime

>>> _strptime('2014-06-16 17:03:58.483000', '%Y-%m-%d %H:%M:%S.%f')

(time.struct_time(tm_year=2014, tm_mon=6, tm_mday=16, tm_hour=17, tm_min=3,
tm_sec=58, tm_wday=0, tm_yday=167, tm_isdst=-1), 483000)


I am not sure what is the best way to fix this problem. Does it make sense
to switch to use _strptime when there is a %f flag presence? I would love
to hear some suggestions so I can learn more the jython codebase, and
hopefully, be able to patch it and give something back to the community.


Thanks, Tony

------------------------------------------------------------------------------

_______________________________________________
Jython-dev mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jython-dev
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.