🏹 Better dates & times for Python
types-python-dateutil
to improve Arrow mypy compatibility. PR https://github.com/arrow-py/arrow/pull/1102
setup.py
/Twine to pyproject.toml
/Flit for packaging and distribution..readthedocs.yaml
configuration file for continued ReadTheDocs support.xelatex
for pdf generation in documentation.requirements.txt
, requirements-docs.txt
and requirements-tests.txt
.flake8-annotations
package for type linting in pre-commit. >>> import arrow
>>> now = arrow.now()
>>> four_month_shift = now.shift(months=4)
>>> now.humanize(four_month_shift, granularity="quarter")
'a quarter ago'
>>> four_month_shift.humanize(now, granularity="quarter")
'in a quarter'
>>> thirteen_month_shift = now.shift(months=13)
>>> thirteen_month_shift.humanize(now, granularity="quarter")
'in 4 quarters'
>>> now.humanize(thirteen_month_shift, granularity="quarter")
'4 quarters ago'
humanize
now raises a ValueError
.Full Diff: https://github.com/arrow-py/arrow/compare/1.2.0...1.2.1
Decimal
as input to arrow.get()
.dehumanize
.A
and hh
.arrow.get()
should now properly pass the tzinfo
argument to the Arrow constructor. See PR #968 for more info._format_timeframe()
.requirements.txt
to requirements-dev.txt
to prevent confusion with the dependencies in setup.py
.dehumanize
method for Arrow
objects. This takes human readable input and uses it to perform relative time shifts, for example: >>> arw
<Arrow [2021-04-26T21:06:14.256803+00:00]>
>>> arw.dehumanize("8 hours ago")
<Arrow [2021-04-26T13:06:14.256803+00:00]>
>>> arw.dehumanize("in 4 days")
<Arrow [2021-04-30T21:06:14.256803+00:00]>
>>> arw.dehumanize("in an hour 34 minutes 10 seconds")
<Arrow [2021-04-26T22:40:24.256803+00:00]>
>>> arw.dehumanize("hace 2 años", locale="es")
<Arrow [2019-04-26T21:06:14.256803+00:00]>
span("week")
, for example: >>> arw
<Arrow [2021-04-26T21:06:14.256803+00:00]>
>>> arw.isoweekday()
1 # Monday
>>> arw.span("week")
(<Arrow [2021-04-26T00:00:00+00:00]>, <Arrow [2021-05-02T23:59:59.999999+00:00]>)
>>> arw.span("week", week_start=4)
(<Arrow [2021-04-22T00:00:00+00:00]>, <Arrow [2021-04-28T23:59:59.999999+00:00]>)
"en-gb"
) rather than an underscore ("en_gb"
) however this change is backward compatible._init_subclass
. This now allows subclassing of locales, for example: >>> from arrow.locales import EnglishLocale
>>> class Klingon(EnglishLocale):
... names = ["tlh"]
...
>>> from arrow import locales
>>> locales.get_locale("tlh")
<__main__.Klingon object at 0x7f7cd1effd30>
arrow.get(2021, 3, 9)
construction.mypy --strict
.humanize
month tests are fixed.OverflowError
that could occur when running Arrow on a 32-bit OS.py.typed
file is now bundled with the Arrow package to conform to PEP 561.