From 3a83f109882c3e35655419f0a172191b89c9c1a7 Mon Sep 17 00:00:00 2001 From: Timo Furrer Date: Sun, 2 Dec 2018 13:30:45 +0000 Subject: [PATCH 1/2] Use pendulum >= 2.0.2. Closes #160 --- Pipfile | 5 +++++ maya/core.py | 8 +++++--- setup.py | 2 +- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/Pipfile b/Pipfile index fd7b839..7b8364b 100644 --- a/Pipfile +++ b/Pipfile @@ -1,3 +1,8 @@ +[[source]] +name = "pypi" +url = "https://pypi.org/simple" +verify_ssl = true + [dev-packages] freezegun = "*" pytest = "*" diff --git a/maya/core.py b/maya/core.py index 2920fd0..cdf018b 100644 --- a/maya/core.py +++ b/maya/core.py @@ -346,7 +346,6 @@ class MayaDT(object): except KeyError: pass - dt.set_formatter("alternative") delta = humanize.time.abs_timedelta( timedelta(seconds=(self.epoch - now().epoch))) @@ -497,7 +496,7 @@ class MayaInterval(object): 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) @@ -740,7 +739,7 @@ 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, timezone='UTC', day_first=False, year_first=True, strict=False): """"Returns a MayaDT instance for the machine-produced moment specified. Powered by pendulum. @@ -755,11 +754,14 @@ def parse(string, timezone='UTC', day_first=False, year_first=True): between YDM and YMD. (default: False) year_first -- if true, the first value (e.g. 2016/05/01) is parsed as year (default: True) + strict -- if False, allow pendulum to fall back on datetime parsing + if pendulum's own parsing fails """ options = {} options['tz'] = timezone options['day_first'] = day_first options['year_first'] = year_first + options['strict'] = strict dt = pendulum.parse(str(string), **options) return MayaDT.from_datetime(dt) diff --git a/setup.py b/setup.py index c28ada9..883faa6 100755 --- a/setup.py +++ b/setup.py @@ -25,7 +25,7 @@ required = [ 'pytz', 'dateparser>=0.7.0', 'tzlocal', - 'pendulum>=1.0, <=1.5.1', + 'pendulum>=2.0.2', 'snaptime' ] From 6522525d7c520825b2c6fa50886e964f9eb32d51 Mon Sep 17 00:00:00 2001 From: Timo Furrer Date: Sun, 2 Dec 2018 13:37:48 +0000 Subject: [PATCH 2/2] alpha release: 0.6.0a1 --- maya/__version__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/maya/__version__.py b/maya/__version__.py index 2b8877c..351b942 100644 --- a/maya/__version__.py +++ b/maya/__version__.py @@ -1 +1 @@ -__version__ = '0.5.0' +__version__ = '0.6.0a1'