A year-month datatype for Python.
Project description
mp-yearmonth
A year-month datatype for Python.
Installation
pip install mp-yearmonth
Usage
from mp_yearmonth import YearMonth
ym = YearMonth(2019, 1)
print(ym) # 2019-01
Parsing ISO 8601 strings:
ym = YearMonth.parse("2019-01")
print(ym.year) # 2019
print(ym.month) # 1
Comparisons:
ym1 = YearMonth(2019, 1)
ym2 = YearMonth(2019, 2)
print(ym1 < ym2) # True
Addition:
ym = YearMonth(2019, 1)
ym += 1
print(ym) # 2019-02
Range:
ym1 = YearMonth(2019, 1)
ym2 = YearMonth(2019, 3)
for ym in YearMonth.range(ym1, ym2):
print(ym) # 2019-01, 2019-02, 2019-03
License
mp-yearmonth is licensed under the MIT license. See LICENSE for details.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
mp_yearmonth-0.1.0.tar.gz
(3.3 kB
view hashes)
Built Distribution
Close
Hashes for mp_yearmonth-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 18b64e8a75747acc0ee2b1545c4ab533bb428531f15f3f984d36c4ea615b3085 |
|
MD5 | 1428f60be4a02f7f4d89c13b3d7bf1ca |
|
BLAKE2b-256 | 4932106b144f3732ccf70438388c4474cbd2d27b9a783c3967a65bb74848f416 |