-
-
Notifications
You must be signed in to change notification settings - Fork 678
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Negative timestamp parsing on windows: timestamp out of range for platform localtime()/gmtime() function #668
Comments
@bollwyvl thanks for reporting this. This is due to the new regression tests we added as part of the fix for #662. It seems that datetime on Windows does not play nicely with negative timestamps (ref: https://stackoverflow.com/questions/36179914). I will need to do some more investigating, but this should not be an issue if you are not using negative time stamps :). |
Thanks for the clarification! Merged -1 minutes from now!
…On Tue, Sep 10, 2019 at 9:47 PM Jad Chaar ***@***.***> wrote:
@bollwyvl <https://github.com/bollwyvl> thanks for reporting this. This
is due to the new regression tests we added as part of the fix for #662
<#662>. It seems that datetime
on Windows does not play nicely with negative timestamps (ref:
https://stackoverflow.com/questions/36179914).
I will need to do some more investigating, but this should not be an issue
if you are not using negative time stamps :).
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#668>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAALCRHNHBYQSSOCOWMHWN3QJBE3ZANCNFSM4IVNUWQA>
.
|
@systemcatch I don't think Arrow ever properly supported negative timestamps on Windows. I was able to configure Travis CI to execute a test run Windows, so we can ignore these tests on Windows for now until we find a more permanent solution. We may need to replace all the if timestamp < 0:
sec = 0
microsec = 0
if isinstance(timestamp, int):
sec = timestamp
else:
whole, frac = str(timestamp).split(".")
sec = int(whole)
microsec = int(frac) * -1
dt = datetime(1970, 1, 1) + timedelta(seconds=sec, microseconds=microsec)
else:
dt = datetime.fromtimestamp(timestamp, tzinfo) For those that may be unaware, negative timestamps are useful for getting times before the epoch (1970-01-01). |
@jadchaar I just tried it on my Windows work machine and you're right it probably never worked. (arrow) C:\Users\Chris>python
Python 3.7.4 (tags/v3.7.4:e09359112e, Jul 8 2019, 20:34:20) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import arrow
>>> arrow.__version__
'0.14.2'
>>> arrow.get(-15675657)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\Chris\arrow\lib\site-packages\arrow\api.py", line 21, in get
return _factory.get(*args, **kwargs)
File "C:\Users\Chris\arrow\lib\site-packages\arrow\factory.py", line 155, in get
return self.type.utcfromtimestamp(arg)
File "C:\Users\Chris\arrow\lib\site-packages\arrow\arrow.py", line 166, in utcfromtimestamp
dt = datetime.utcfromtimestamp(timestamp)
OSError: [Errno 22] Invalid argument |
Yeah that is quite peculiar. I wonder why the functionality of |
Hey @bollwyvl, we have released 0.15.2, which includes the fix for tests on Windows :). |
Thanks for arrow!
Over on conda-forge, our build of 0.15.1 turned up this test fail on windows:
Excluding this on windows got things going again, but is this a cause for concern?
The text was updated successfully, but these errors were encountered: