@@ -636,7 +636,7 @@ the ``now()`` is created in the same timezone as the instance.
636636 born = pendulum.from_date(1987 , 4 , 23 )
637637 not_birthday = pendulum.from_date(2014 , 9 , 26 )
638638 birthday = pendulum.from_date(2014 , 2 , 23 )
639- past_birthday = pendulum.now().sub (years = 50 )
639+ past_birthday = pendulum.now().subtract (years = 50 )
640640
641641 born.is_birthday(not_birthday)
642642 False
@@ -650,8 +650,8 @@ the ``now()`` is created in the same timezone as the instance.
650650 Addition and Subtraction
651651========================
652652
653- To easily adding and subtracting time, you can use the ``add() `` and ``sub () ``
654- methods` .
653+ To easily adding and subtracting time, you can use the ``add() `` and ``subtract () ``
654+ methods.
655655Each method returns a new ``Pendulum `` instance.
656656
657657.. code-block :: python
@@ -667,68 +667,68 @@ Each method returns a new ``Pendulum`` instance.
667667 ' 2017-01-31 00:00:00'
668668 dt = dt.add(years = 1 )
669669 ' 2018-01-31 00:00:00'
670- dt = dt.sub (years = 1 )
670+ dt = dt.subtract (years = 1 )
671671 ' 2017-01-31 00:00:00'
672- dt = dt.sub (years = 5 )
672+ dt = dt.subtract (years = 5 )
673673 ' 2012-01-31 00:00:00'
674674
675675 dt = dt.add(months = 60 )
676676 ' 2017-01-31 00:00:00'
677677 dt = dt.add(months = 1 )
678678 ' 2017-02-28 00:00:00'
679- dt = dt.sub (months = 1 )
679+ dt = dt.subtract (months = 1 )
680680 ' 2017-01-28 00:00:00'
681- dt = dt.sub (months = 60 )
681+ dt = dt.subtract (months = 60 )
682682 ' 2012-01-28 00:00:00'
683683
684684 dt = dt.add(days = 29 )
685685 ' 2012-02-26 00:00:00'
686686 dt = dt.add(days = 1 )
687687 ' 2012-02-27 00:00:00'
688- dt = dt.sub (days = 1 )
688+ dt = dt.subtract (days = 1 )
689689 ' 2012-02-26 00:00:00'
690- dt = dt.sub (days = 29 )
690+ dt = dt.subtract (days = 29 )
691691 ' 2012-01-28 00:00:00'
692692
693693 dt = dt.add(weeks = 3 )
694694 ' 2012-02-18 00:00:00'
695695 dt = dt.add(weeks = 1 )
696696 ' 2012-02-25 00:00:00'
697- dt = dt.sub (weeks = 1 )
697+ dt = dt.subtract (weeks = 1 )
698698 ' 2012-02-18 00:00:00'
699- dt = dt.sub (weeks = 3 )
699+ dt = dt.subtract (weeks = 3 )
700700 ' 2012-01-28 00:00:00'
701701
702702 dt = dt.add(hours = 24 )
703703 ' 2012-01-29 00:00:00'
704704 dt = dt.add(hours = 1 )
705705 ' 2012-02-25 01:00:00'
706- dt = dt.sub (hours = 1 )
706+ dt = dt.subtract (hours = 1 )
707707 ' 2012-02-29 00:00:00'
708- dt = dt.sub (hours = 24 )
708+ dt = dt.subtract (hours = 24 )
709709 ' 2012-01-28 00:00:00'
710710
711711 dt = dt.add(minutes = 61 )
712712 ' 2012-01-28 01:01:00'
713713 dt = dt.add(minutes = 1 )
714714 ' 2012-01-28 01:02:00'
715- dt = dt.sub (minutes = 1 )
715+ dt = dt.subtract (minutes = 1 )
716716 ' 2012-01-28 01:01:00'
717- dt = dt.sub (minutes = 24 )
717+ dt = dt.subtract (minutes = 24 )
718718 ' 2012-01-28 00:00:00'
719719
720720 dt = dt.add(seconds = 61 )
721721 ' 2012-01-28 00:01:01'
722722 dt = dt.add(seconds = 1 )
723723 ' 2012-01-28 00:01:02'
724- dt = dt.sub (seconds = 1 )
724+ dt = dt.subtract (seconds = 1 )
725725 ' 2012-01-28 00:01:01'
726- dt = dt.sub (seconds = 61 )
726+ dt = dt.subtract (seconds = 61 )
727727 ' 2012-01-28 00:00:00'
728728
729729 dt = dt.add(years = 3 , months = 2 , days = 6 , hours = 12 , minutes = 31 , seconds = 43 )
730730 ' 2015-04-03 12:31:43'
731- dt = dt.sub (years = 3 , months = 2 , days = 6 , hours = 12 , minutes = 31 , seconds = 43 )
731+ dt = dt.subtract (years = 3 , months = 2 , days = 6 , hours = 12 , minutes = 31 , seconds = 43 )
732732 ' 2012-01-28 00:00:00'
733733
734734 # You can also add or remove a timedelta
@@ -737,6 +737,11 @@ Each method returns a new ``Pendulum`` instance.
737737 dt.sub_timedelta(timedelta(hours = 3 , minutes = 4 , seconds = 5 ))
738738 ' 2012-01-28 00:00:00'
739739
740+ .. note ::
741+
742+ Passing negative values to ``add() `` is also possible and will act exactly
743+ like ``subtract() ``
744+
740745
741746Difference
742747==========
@@ -770,7 +775,7 @@ This will default to ``True``, return the absolute value. The comparisons are do
770775 dt = pendulum.create(2012 , 1 , 31 , 0 )
771776 dt.diff(dt.add(months = 1 )).in_days()
772777 29
773- dt.diff(dt.sub (months = 1 ), False ).in_days()
778+ dt.diff(dt.subtract (months = 1 ), False ).in_days()
774779 - 31
775780
776781 dt = pendulum.create(2012 , 4 , 30 , 0 )
@@ -823,25 +828,25 @@ You may also pass ``True`` as a 2nd parameter to remove the modifiers `ago`, `fr
823828 # The most typical usage is for comments
824829 # The instance is the date the comment was created
825830 # and its being compared to default now()
826- pendulum.now().sub (dayss = 1 ).diff_for_humans()
831+ pendulum.now().subtract (dayss = 1 ).diff_for_humans()
827832 ' 5 days ago'
828833
829- pendulum.now().diff_for_humans(Pendulum.now().sub (years = 1 ))
834+ pendulum.now().diff_for_humans(Pendulum.now().subtract (years = 1 ))
830835 ' 1 year after'
831836
832837 dt = pendulum.from_date(2011 , 8 , 1 )
833838 dt.diff_for_humans(dt.add(months = 1 ))
834839 ' 1 month before'
835- dt.diff_for_humans(dt.sub (months = 1 ))
840+ dt.diff_for_humans(dt.subtract (months = 1 ))
836841 ' 1 month after'
837842
838843 pendulum.now().add(seconds = 5 ).diff_for_humans()
839844 ' 5 seconds from now'
840845
841- pendulum.now().sub (days = 24 ).diff_for_humans()
846+ pendulum.now().subtract (days = 24 ).diff_for_humans()
842847 ' 3 weeks ago'
843848
844- pendulum.now().sub (days = 24 ).diff_for_humans(absolute = True )
849+ pendulum.now().subtract (days = 24 ).diff_for_humans(absolute = True )
845850 ' 3 weeks'
846851
847852 You can also change the locale of the string either globally by using ``pendulum.set_locale('fr') ``
0 commit comments