Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace ".replace" with new ".shift" function in docs #406

Merged
merged 1 commit into from
Jan 7, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions arrow/arrow.py
Original file line number Diff line number Diff line change
Expand Up @@ -710,11 +710,11 @@ def humanize(self, other=None, locale='en_us', only_distance=False, granularity=
:param granularity: (optional) defines the precision of the output. Set it to strings 'second', 'minute', 'hour', 'day', 'month' or 'year'.
Usage::

>>> earlier = arrow.utcnow().replace(hours=-2)
>>> earlier = arrow.utcnow().shift(hours=-2)
>>> earlier.humanize()
'2 hours ago'

>>> later = later = earlier.replace(hours=4)
>>> later = later = earlier.shift(hours=4)
>>> later.humanize(earlier)
'in 4 hours'

Expand Down
12 changes: 6 additions & 6 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ Quickstart
>>> utc
<Arrow [2013-05-11T21:23:58.970460+00:00]>

>>> utc = utc.replace(hours=-1)
>>> utc = utc.shift(hours=-1)
>>> utc
<Arrow [2013-05-11T20:23:58.970460+00:00]>

Expand Down Expand Up @@ -220,7 +220,7 @@ Or, get one with attributes shifted forward or backward:

.. code-block:: python

>>> arw.replace(weeks=+3)
>>> arw.shift(weeks=+3)
<Arrow [2013-06-02T03:29:35.334214+00:00]>

Even replace the timezone without altering other attributes:
Expand Down Expand Up @@ -274,7 +274,7 @@ Humanize relative to now:

.. code-block:: python

>>> past = arrow.utcnow().replace(hours=-1)
>>> past = arrow.utcnow().shift(hours=-1)
>>> past.humanize()
'an hour ago'

Expand All @@ -283,15 +283,15 @@ Or another Arrow, or datetime:
.. code-block:: python

>>> present = arrow.utcnow()
>>> future = present.replace(hours=2)
>>> future = present.shift(hours=2)
>>> future.humanize(present)
'in 2 hours'

Support for a growing number of locales (see `locales.py` for supported languages):

.. code-block:: python

>>> future = arrow.utcnow().replace(hours=1)
>>> future = arrow.utcnow().shift(hours=1)
>>> future.humanize(a, locale='ru')
'через 2 час(а,ов)'

Expand Down Expand Up @@ -363,7 +363,7 @@ Use factories to harness Arrow's module API for a custom Arrow-derived type. Fi
... xmas = arrow.Arrow(self.year, 12, 25)
...
... if self > xmas:
... xmas = xmas.replace(years=1)
... xmas = xmas.shift(years=1)
...
... return (xmas - self).days

Expand Down