Support for 9 fractional second digits (ns)
- Dominant language
- Python
- Stars
- 9.1k
- Forks
- 784
- PR merge metrics
- No merged PRs in 30d
Description
Firstly, 9 fractional second digits is approved in ISO8610(RFC3339).
> ... one or more digits representing a decimal fraction of a second
as it put (https://www.w3.org/TR/NOTE-datetime).
A 9 fractional second digits ISO8610 datetime can be generated in a Linux/Unix environment(not OS X) as this way:
`$ date --rfc-3339=ns`
`2016-06-23 16:40:27.329428631+08:00`
I'm using Arrow 0.7.0, with python 2.7.11, on both OS X(10.11.5) and Ubuntu 14.04.
As for Arrow implementation in my environments:
`>>> import arrow`
`>>> s1='2016-06-23 16:40:27.329428631+08:00'`
`>>> arrow.get(s1)`
`Traceback (most recent call last):
File "", line 1, in
File "/usr/lib/python2.7/site-packages/arrow/arrow.py", line 286, in __repr__
return '<{0} [{1}]>'.format(self.__class__.__name__, self.__str__())
File "/usr/lib/python2.7/site-packages/arrow/arrow.py", line 289, in __str__
return self._datetime.isoformat()
ValueError: tzinfo.utcoffset() returned 1440; must be in -1439 .. 1439`
But works fine in case of 6 fractional second digits:
`>>> import arrow`
`>>> s2='2016-06-23 16:40:27.329428+08:00'`
`>>> arrow.get(s2)`
``
Lastly, I have a quick look in parse.py, the reason of the above seems to be Arrow never support a 9 fractional second digits datetime string, and only support up to 6 digits (the _FORMAT_RE in https://github.com/crsmithdev/arrow/blob/master/arrow/parser.py line 17).
Update:
I have noticed that datetime itself do not support 9 fractional second digits either (https://docs.python.org/2/library/datetime.html#datetime.datetime.microsecond ):
> datetime.microsecond
> In range(1000000).
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.