Skip to content

Commit 6bdbc7f

Browse files
author
Hugo Osvaldo Barrera
committed
Stop using deprecated parsedatetime style
1 parent d0ca7f4 commit 6bdbc7f

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

todoman/formatters.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ def __init__(self, date_format='%Y-%m-%d', time_format='%H:%M',
2424
self.tz = tz_override or tzlocal()
2525
self.now = datetime.datetime.now().replace(tzinfo=self.tz)
2626

27-
self._parsedatetime_calendar = parsedatetime.Calendar()
27+
self._parsedatetime_calendar = parsedatetime.Calendar(
28+
version=parsedatetime.VERSION_CONTEXT_STYLE,
29+
)
2830

2931
def simple_action(self, action, todo):
3032
return '{} "{}"'.format(action, todo.summary)
@@ -158,11 +160,9 @@ def _parse_datetime_naive(self, dt):
158160
except ValueError:
159161
pass
160162

161-
rv, certainty = self._parsedatetime_calendar.parse(dt)
162-
if not certainty:
163-
raise ValueError(
164-
'Time description not recognized: {}' .format(dt)
165-
)
163+
rv, pd_ctx = self._parsedatetime_calendar.parse(dt)
164+
if not pd_ctx.hasDateOrTime:
165+
raise ValueError('Time description not recognized: {}' .format(dt))
166166
return datetime.datetime.fromtimestamp(mktime(rv))
167167

168168
def format_database(self, database):

0 commit comments

Comments
 (0)