Skip to content
This repository has been archived by the owner on Sep 14, 2018. It is now read-only.

datetime.strptime with %f loses precision below milliseconds #1169

Closed
pekkaklarck opened this issue Feb 21, 2015 · 1 comment
Closed

datetime.strptime with %f loses precision below milliseconds #1169

pekkaklarck opened this issue Feb 21, 2015 · 1 comment

Comments

@pekkaklarck
Copy link

C:\Users\peke>ipy
IronPython 2.7.5 (2.7.5.0) on .NET 4.0.30319.18444 (32-bit)
Type "help", "copyright", "credits" or "license" for more information.
>>> from datetime import datetime
>>> datetime.strptime("2013-11-29T16:38:12.507666", "%Y-%m-%dT%H:%M:%S.%f")
datetime.datetime(2013, 11, 29, 16, 38, 12, 507000)
>>>

C:\Users\peke>python
Python 2.7.3 (default, Apr 10 2012, 23:24:47) [MSC v.1500 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from datetime import datetime
>>> datetime.strptime("2013-11-29T16:38:12.507666", "%Y-%m-%dT%H:%M:%S.%f")
datetime.datetime(2013, 11, 29, 16, 38, 12, 507666)
>>>

Notice that prior to IronPython 2.7.5 datetime.strptime didn't support %f at all:
https://ironpython.codeplex.com/workitem/34706

@pekkaklarck pekkaklarck changed the title datetime.strptime with datetime.strptime with %f loses precision below milliseconds Feb 21, 2015
@pekkaklarck
Copy link
Author

This problem with fromtimestamp is probably related:

IronPython 2.7.5 (2.7.5.0) on .NET 4.0.30319.18444 (32-bit)
Type "help", "copyright", "credits" or "license" for more information.
>>> from datetime import datetime
>>> datetime.fromtimestamp(1399410716.123).microsecond
122000

IIRC, the above returned 122999 with earlier IronPython versions. IPY 2.7.5 dropping precision below milliseconds would explain how that is turned into 122000.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant