'Increment date with arrow in python not changing properties

I am using .replace and .shift method to increment/decrement an arrow date. However the behaviour is completely unexpected. See the python session below as example.

>>> import arrow
>>> ref = arrow.get('2019-08-01', 'YYYY-MM-DD')
>>> ref.weekday()
3
>>> ref.day
1
>>> ref.shift(days=1)
<Arrow [2019-08-02T00:00:00+00:00]>
>>> ref.weekday()
3
>>> ref.day
1
>>> ref
<Arrow [2019-08-01T00:00:00+00:00]>
>>> 

After I shifted the arrow by one day I would expect weekday and day properties to be incremented. However they stay the same. Any explanation to this?

Using replace does the same thing.



Solution 1:[1]

Try this: ref = ref.shift(days=1)

shift doesn't update the object, it returns an updated object...

C:\Users\deanv>python
Python 3.7.4 (tags/v3.7.4:e09359112e, Jul  8 2019, 20:34:20) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import arrow
>>> ref = arrow.get('2019-08-01', 'YYYY-MM-DD')
>>> ref.weekday()
3
>>> ref.day
1
>>> ref = ref.shift(days=1)
>>> ref.weekday()
4
>>> ref.day
2
>>>

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1