archrelease: copy trunk to community-any
[ArchLinux/community.git] / python-jinja-time / repos / community-any / python-jinja-time-0.2.0-arrow_shift.patch
blob04d2993c453fb270b6996031741eb7d11f9726ee
1 From aa4af9af0a0a5111a8ad21bc1b43bbdb586ee8af Mon Sep 17 00:00:00 2001
2 From: Vincent Bernat <vincent@bernat.ch>
3 Date: Sun, 3 Nov 2019 07:48:08 +0100
4 Subject: [PATCH] Use shift() instead of replace() to modify dates
6 Previously, the `replace()` method from arrow was shifting the date
7 when the arguments were using the plural form. Since Arrow 0.9.0, this
8 has been deprecated in favor of a `shift()` method. Arrow 0.14.5
9 completely removed the ability for `replace()` to shift dates. This
10 leads to errors like `AttributeError: unknown attribute: "hours"` when
11 using plural form.
13 This commit replace the use of `replace()` by `shift()` since the
14 intent is always to shift the current date.
15 ---
16 jinja2_time/jinja2_time.py | 6 +++---
17 setup.py | 4 ++--
18 2 files changed, 5 insertions(+), 5 deletions(-)
20 diff --git a/jinja2_time/jinja2_time.py b/jinja2_time/jinja2_time.py
21 index ce713cb..717c8a0 100755
22 --- a/jinja2_time/jinja2_time.py
23 +++ b/jinja2_time/jinja2_time.py
24 @@ -19,11 +19,11 @@ def _datetime(self, timezone, operator, offset, datetime_format):
25 d = arrow.now(timezone)
27 # Parse replace kwargs from offset and include operator
28 - replace_params = {}
29 + shift_params = {}
30 for param in offset.split(','):
31 interval, value = param.split('=')
32 - replace_params[interval.strip()] = float(operator + value.strip())
33 - d = d.replace(**replace_params)
34 + shift_params[interval.strip()] = float(operator + value.strip())
35 + d = d.shift(**shift_params)
37 if datetime_format is None:
38 datetime_format = self.environment.datetime_format