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

Pendulum 2.0.2 compatibility #161

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -42,6 +42,7 @@ htmlcov/
.coverage
.coverage.*
.cache
.pytest_cache/
nosetests.xml
coverage.xml
*,cover
Expand Down
8 changes: 5 additions & 3 deletions maya/core.py
Expand Up @@ -346,7 +346,6 @@ def slang_date(self, locale="en"):
except KeyError:
pass

dt.set_formatter("alternative")
delta = humanize.time.abs_timedelta(
timedelta(seconds=(self.epoch - now().epoch)))

Expand Down Expand Up @@ -497,7 +496,7 @@ def from_iso8601(cls, s):

try:
end = parse(end)
except pendulum.parsing.exceptions.ParserError as e:
except (pendulum.parsing.exceptions.ParserError, TypeError) as e:
end = cls.parse_iso8601_duration(end, start=start)

return cls(start=start, end=end)
Expand Down Expand Up @@ -740,14 +739,16 @@ def when(string, timezone='UTC', prefer_dates_from='current_period'):
return MayaDT.from_datetime(dt)


def parse(string, timezone='UTC', day_first=False, year_first=True):
def parse(string, strict=False, timezone='UTC', day_first=False, year_first=True):
""""Returns a MayaDT instance for the machine-produced moment specified.

Powered by pendulum.
Accepts most known formats. Useful for working with data.

Keyword Arguments:
string -- string to be parsed
strict -- if false, allow pendulum to fall back on datetime parsing
if pendulum's own parsing fails
timezone -- timezone referenced from (default: 'UTC')
day_first -- if true, the first value (e.g. 01/05/2016)
is parsed as day.
Expand All @@ -757,6 +758,7 @@ def parse(string, timezone='UTC', day_first=False, year_first=True):
is parsed as year (default: True)
"""
options = {}
options['strict'] = strict
options['tz'] = timezone
options['day_first'] = day_first
options['year_first'] = year_first
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Expand Up @@ -25,7 +25,7 @@
'pytz',
'dateparser>=0.7.0',
'tzlocal',
'pendulum>=1.0, <=1.5.1',
'pendulum>=2.0.2',
'snaptime'
]

Expand Down