=====
month
=====
.. image:: https://img.shields.io/pypi/v/datetime-month.svg
:target: https://pypi.python.org/pypi/datetime-month
.. image:: https://github.com/yitistica/month/actions/workflows/pre-release-test.yml/badge.svg
:target: https://github.com/yitistica/month/actions/workflows/pre-release-test.yml
.. image:: https://readthedocs.org/projects/month/badge/?version=latest
:target: https://month.readthedocs.io/en/latest/?badge=latest
:alt: Documentation Status
A package that handles calendar months and arithmetic operation of months.
The package comprises two modules: **month** and **x_month**.
**month** module provides the base classes for manipulating month-level time.
**x_month** module extends the base classes from the *month* module to include additional functionalities.
Installation
------------
.. code-block::
pip install datetime-month
Features & Usage
----------------
To construct a month object:
.. code-block:: python
from month import Month
from month import XMonth # extended month;
m = Month(2020, 4)
xm = XMonth(2020, 4)
Additional construction methods below can be used to translate a *tuple* (year, month), a *isoformat* string,
an *ordinal* int and *month-format* string into a **Month** object.
.. code-block:: python
# constructed from a (year, month) tuple:
m = Month.fromtuple((2019, 11))
# isoformat is defined as a str in "year-month" format:
m = Month.fromisoformat('2019-12')
# ordinal (as in date units):
m = Month.fromordinal(737390)
# using string format like datetime:
m = Month.strptime('2019/1', '%Y/%m')
For the representation of the difference between two months, we can use **Mdelta** (similar to *timedelta* in datetime modules). To construct:
.. code-block:: python
from month import MDelta
delta = Mdelta(2) # Mdelta(months), months: int;
**Mdelta** supports comparisons using operators. It also supports some arithmetic operations (addition, subtraction, and multiplication)
among Mdelta objects or with Month objects or int objects.
.. code-block:: python
Mdelta(2) < Mdelta(3) # returns bool;
Mdelta(2) - Mdelta(3) # returns Mdelta(-1);
Mdelta(2) * 2 # returns Mdelta(4);
Some arithmetic operations and comparisons are also supported for **Month** objects.
.. code-block:: python
Month(2019, 11).add(MDelta(2)) # returns Month(2020, 1);
Month(2020, 04) + Mdelta(2) # returns Month(2020, 6);
Month(2020, 1) - 2 # returns Month(2019, 11);
Month(2020, 04) <= Month(2020, 06) # returns True;
**XMonth** is an extended version of **Month** by including some convenient manipulation and sub-level operations.
.. code-block:: python
xm = XMonth(2019, 11)
xm.days() # returns total days in the month;
xm.first_date() # returns date(2019,11,1)
# iterate dates within the month in increment by step days:
xm.dates(step=2)
# iterate months in a given range:
XMonth.range(starting_month, ending_month, step=1)
License
--------
* Free software: MIT license
Credits
-------
The repo was initiated using `audreyr/cookiecutter-pypackage`_ project template.
.. _`audreyr/cookiecutter-pypackage`: https://github.com/audreyr/cookiecutter-pypackage
=======
History
=======
0.1.0 (2020-03-21)
------------------
* First release on PyPI.
1.0.3 (2022-10-11)
------------------
* **FIX:** Fix wrong package metadata in setup - `#2`_.
.. _#2: https://github.com/yitistica/month/issues/2
1.0.4 (2022-11-10)
------------------
* **FIX:** Fix arithmetic operation on XMonth returning base class Month object instead of XMonth - `#8`_. Contributed by `@ramwin <https://github.com/ramwin>`_. Thank you!
.. _#8: https://github.com/yitistica/month/pull/8
1.0.5 (2024-02-15)
------------------
* Add compatibility with Python 3.11 & 3.12.
1.0.6 (2024-02-15)
------------------
* Fix ReadMe note.
Raw data
{
"_id": null,
"home_page": "https://github.com/yitistica/month",
"name": "datetime-month",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.6",
"maintainer_email": "",
"keywords": "month,date",
"author": "Yi Q",
"author_email": "yitistica@outlook.com",
"download_url": "https://files.pythonhosted.org/packages/7e/93/cb848b6806837b0eb98db3dece687b9280672a55e7aeace71244c63bba9c/datetime-month-1.0.6.tar.gz",
"platform": null,
"description": "=====\nmonth\n=====\n\n\n.. image:: https://img.shields.io/pypi/v/datetime-month.svg\n :target: https://pypi.python.org/pypi/datetime-month\n\n.. image:: https://github.com/yitistica/month/actions/workflows/pre-release-test.yml/badge.svg\n :target: https://github.com/yitistica/month/actions/workflows/pre-release-test.yml\n\n.. image:: https://readthedocs.org/projects/month/badge/?version=latest\n :target: https://month.readthedocs.io/en/latest/?badge=latest\n :alt: Documentation Status\n\n\nA package that handles calendar months and arithmetic operation of months.\n\nThe package comprises two modules: **month** and **x_month**.\n**month** module provides the base classes for manipulating month-level time.\n**x_month** module extends the base classes from the *month* module to include additional functionalities.\n\n\nInstallation\n------------\n\n.. code-block::\n\n pip install datetime-month\n\n\nFeatures & Usage\n----------------\n\nTo construct a month object:\n\n.. code-block:: python\n\n from month import Month\n from month import XMonth # extended month;\n\n m = Month(2020, 4)\n xm = XMonth(2020, 4)\n\nAdditional construction methods below can be used to translate a *tuple* (year, month), a *isoformat* string,\nan *ordinal* int and *month-format* string into a **Month** object.\n\n.. code-block:: python\n\n # constructed from a (year, month) tuple:\n m = Month.fromtuple((2019, 11))\n\n # isoformat is defined as a str in \"year-month\" format:\n m = Month.fromisoformat('2019-12')\n\n # ordinal (as in date units):\n m = Month.fromordinal(737390)\n\n # using string format like datetime:\n m = Month.strptime('2019/1', '%Y/%m')\n\nFor the representation of the difference between two months, we can use **Mdelta** (similar to *timedelta* in datetime modules). To construct:\n\n.. code-block:: python\n\n from month import MDelta\n delta = Mdelta(2) # Mdelta(months), months: int;\n\n**Mdelta** supports comparisons using operators. It also supports some arithmetic operations (addition, subtraction, and multiplication)\namong Mdelta objects or with Month objects or int objects.\n\n.. code-block:: python\n\n Mdelta(2) < Mdelta(3) # returns bool;\n Mdelta(2) - Mdelta(3) # returns Mdelta(-1);\n Mdelta(2) * 2 # returns Mdelta(4);\n\nSome arithmetic operations and comparisons are also supported for **Month** objects.\n\n.. code-block:: python\n\n Month(2019, 11).add(MDelta(2)) # returns Month(2020, 1);\n Month(2020, 04) + Mdelta(2) # returns Month(2020, 6);\n Month(2020, 1) - 2 # returns Month(2019, 11);\n Month(2020, 04) <= Month(2020, 06) # returns True;\n\n**XMonth** is an extended version of **Month** by including some convenient manipulation and sub-level operations.\n\n.. code-block:: python\n\n xm = XMonth(2019, 11)\n\n xm.days() # returns total days in the month;\n\n xm.first_date() # returns date(2019,11,1)\n\n # iterate dates within the month in increment by step days:\n xm.dates(step=2)\n\n # iterate months in a given range:\n XMonth.range(starting_month, ending_month, step=1)\n\nLicense\n--------\n* Free software: MIT license\n\n\nCredits\n-------\nThe repo was initiated using `audreyr/cookiecutter-pypackage`_ project template.\n\n.. _`audreyr/cookiecutter-pypackage`: https://github.com/audreyr/cookiecutter-pypackage\n\n\n=======\nHistory\n=======\n\n\n0.1.0 (2020-03-21)\n------------------\n\n* First release on PyPI.\n\n1.0.3 (2022-10-11)\n------------------\n\n* **FIX:** Fix wrong package metadata in setup - `#2`_.\n\n.. _#2: https://github.com/yitistica/month/issues/2\n\n1.0.4 (2022-11-10)\n------------------\n\n* **FIX:** Fix arithmetic operation on XMonth returning base class Month object instead of XMonth - `#8`_. Contributed by `@ramwin <https://github.com/ramwin>`_. Thank you!\n\n.. _#8: https://github.com/yitistica/month/pull/8\n\n1.0.5 (2024-02-15)\n------------------\n\n* Add compatibility with Python 3.11 & 3.12.\n\n1.0.6 (2024-02-15)\n------------------\n\n* Fix ReadMe note.\n",
"bugtrack_url": null,
"license": "MIT license",
"summary": "a package that handles months.",
"version": "1.0.6",
"project_urls": {
"Homepage": "https://github.com/yitistica/month"
},
"split_keywords": [
"month",
"date"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "7e93cb848b6806837b0eb98db3dece687b9280672a55e7aeace71244c63bba9c",
"md5": "c1f9645a432ab913e1008e7fa647a17a",
"sha256": "72660fddf59b168c5161e24afe757bfa71d702efa1004af1f628a8d0f350b4b6"
},
"downloads": -1,
"filename": "datetime-month-1.0.6.tar.gz",
"has_sig": false,
"md5_digest": "c1f9645a432ab913e1008e7fa647a17a",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.6",
"size": 16218,
"upload_time": "2024-02-15T16:31:03",
"upload_time_iso_8601": "2024-02-15T16:31:03.331254Z",
"url": "https://files.pythonhosted.org/packages/7e/93/cb848b6806837b0eb98db3dece687b9280672a55e7aeace71244c63bba9c/datetime-month-1.0.6.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-02-15 16:31:03",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "yitistica",
"github_project": "month",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [],
"tox": true,
"lcname": "datetime-month"
}