Skip to content
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

Arrow parse negative number relative to epoch on 0.15 not working for strings #662

Closed
JBKahn opened this issue Sep 10, 2019 · 3 comments
Closed
Labels

Comments

@JBKahn
Copy link
Contributor

JBKahn commented Sep 10, 2019

When we upgraded to the latest version it seems the suggested behaviour for parsing strings doesn't allow it to be a negative value relative to epoch.

In [8]: arrow.get(-1565358758)
Out[8]: <Arrow [1920-05-25T10:07:22+00:00]>

In [9]: arrow.get('-1565358758', 'X')
---------------------------------------------------------------------------
ParserMatchError                          Traceback (most recent call last)
<ipython-input-9-9ca34c371f99> in <module>
----> 1 arrow.get('-1565358758', 'X')

/usr/local/lib/python3.7/site-packages/arrow/api.py in get(*args, **kwargs)
     19     """
     20
---> 21     return _factory.get(*args, **kwargs)
     22
     23

/usr/local/lib/python3.7/site-packages/arrow/factory.py in get(self, *args, **kwargs)
    228             # (str, format) -> parse.
    229             elif isstr(arg_1) and (isstr(arg_2) or isinstance(arg_2, list)):
--> 230                 dt = parser.DateTimeParser(locale).parse(args[0], args[1])
    231                 return self.type.fromdatetime(dt, tzinfo=tz)
    232

/usr/local/lib/python3.7/site-packages/arrow/parser.py in parse(self, datetime_string, fmt)
    214         if match is None:
    215             raise ParserMatchError(
--> 216                 "Failed to match '{}' when parsing '{}'".format(fmt, datetime_string)
    217             )
    218

ParserMatchError: Failed to match 'X' when parsing '-1565358758'

@JBKahn JBKahn changed the title Arrow parse negative epoch on 0.15 not working for strings Arrow parse negative number relative to epoch on 0.15 not working for strings Sep 10, 2019
@systemcatch
Copy link
Collaborator

Hey @JBKahn looks like we missed this with all the upgrades, thanks for pointing it out.

@JBKahn
Copy link
Contributor Author

JBKahn commented Sep 10, 2019

NP, The patch I submitted should resolve this one

@jadchaar
Copy link
Member

Hey @JBKahn, we have just released 0.15.1 with this fix. Thanks!

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

No branches or pull requests

3 participants