I am trying to add (shift) 6 hours to an arrow object, but somehow it seems to replace it instead:
>>> import arrow
>>> print(arrow.utcnow(),arrow.utcnow().replace(hour=+6))
2017-04-19T18:29:16.217239+00:00 2017-04-19T06:29:16.217304+00:00
The documentation gives me this example:
arw.replace(weeks=+3)
Why is it not working with hour? What am I doing wrong here?
You need to put an
s
behindhour
:The docs are a bit hasty in their example, but you could deduce it (weeks vs week)
(from the docs)
3
and+3
parse to exactly the same (a positive value of 3), so the plus sign is not the part that makes the shift. It is only the difference betweenweek
andweeks
.In newer versions you can use
.shift(hours=+6)
to avoid being confused, as found in the API docs.