python-calendarweek
===================
python-calendarweek provides a CalendarWeek dataclass for representing one
week in a year, and utility functions to work with it in pure Python or
Django.
Usage
-----
The `CalendarWeek` object
~~~~~~~~~~~~~~~~~~~~~~~~~
The main interface is the `CalendarWeek` object. The following example shows its
interface.
.. code-block:: python
from datetime import date
from calendarweek import CalendarWeek
# Create an object for the third week in 2012
week = CalendarWeek(year=2012, week=3)
# Get the current week (or the week for any date)
week = CalendarWeek.from_date(date.today())
# Short-hand for the current week
week = CalendarWeek()
# Get all weeks within a date range
start = date(2012, 3, 18)
end = date(2012, 4, 19)
weeks = CalendarWeek.weeks_within(start, end)
# Get the last week of a year
week = CalendarWeek.get_last_week_of_year(2012)
# Get the Wednesday of the selected week (or any weekday)
day = week[3]
# Check whether a day is within a week
is_contained = day in week
# Get the week five weeks later
week = week + 5
# Additionally, all comparison operators are implemented
Django utilities
~~~~~~~~~~~~~~~~
Some utilities for Django are contained in the `calendarweek.django` module:
- `i18n_day_names` — Returns a tuple of localised day names
- `i18n_day_abbrs` — Returns a tuple of abbreviated, localised day names
- `i18n_month_names` — Returns a tuple of localised month names
- `i18n_month_abbrs` — Returns a tuple of abbreviated, localised month names
- All the above for suffixed with `_choices` to get a list of tuples ready for a model
or form field's `choices`
- `i18n_js` — A view returning the above as JSON ready to be consumed by a frontend
Raw data
{
"_id": null,
"home_page": "https://edugit.org/AlekSIS/libs/python-calendarweek",
"name": "calendarweek",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.10,<4.0",
"maintainer_email": "",
"keywords": "",
"author": "Dominik George",
"author_email": "nik@naturalnet.de",
"download_url": "https://files.pythonhosted.org/packages/f4/6f/40ae1080331ea03aff921b7c5c099b3acdc8261c21875402635742a7f5d8/calendarweek-0.6.tar.gz",
"platform": null,
"description": "python-calendarweek\n===================\n\npython-calendarweek provides a CalendarWeek dataclass for representing one\nweek in a year, and utility functions to work with it in pure Python or\nDjango.\n\n\nUsage\n-----\n\nThe `CalendarWeek` object\n~~~~~~~~~~~~~~~~~~~~~~~~~\n\nThe main interface is the `CalendarWeek` object. The following example shows its\ninterface.\n\n.. code-block:: python\n\n from datetime import date\n from calendarweek import CalendarWeek\n\n # Create an object for the third week in 2012\n week = CalendarWeek(year=2012, week=3)\n\n # Get the current week (or the week for any date)\n week = CalendarWeek.from_date(date.today())\n\n # Short-hand for the current week\n week = CalendarWeek()\n\n # Get all weeks within a date range\n start = date(2012, 3, 18)\n end = date(2012, 4, 19)\n weeks = CalendarWeek.weeks_within(start, end)\n\n # Get the last week of a year\n week = CalendarWeek.get_last_week_of_year(2012)\n\n # Get the Wednesday of the selected week (or any weekday)\n day = week[3]\n\n # Check whether a day is within a week\n is_contained = day in week\n\n # Get the week five weeks later\n week = week + 5\n\n # Additionally, all comparison operators are implemented\n\n\nDjango utilities\n~~~~~~~~~~~~~~~~\n\nSome utilities for Django are contained in the `calendarweek.django` module:\n\n- `i18n_day_names` \u2014 Returns a tuple of localised day names\n- `i18n_day_abbrs` \u2014 Returns a tuple of abbreviated, localised day names\n- `i18n_month_names` \u2014 Returns a tuple of localised month names\n- `i18n_month_abbrs` \u2014 Returns a tuple of abbreviated, localised month names\n- All the above for suffixed with `_choices` to get a list of tuples ready for a model\n or form field's `choices`\n- `i18n_js` \u2014 A view returning the above as JSON ready to be consumed by a frontend\n",
"bugtrack_url": null,
"license": "Apache-2.0",
"summary": "Utilities for working with calendar weeks in Python and Django",
"version": "0.6",
"project_urls": {
"Documentation": "https://edugit.org/AlekSIS/libs/python-calendarweek",
"Homepage": "https://edugit.org/AlekSIS/libs/python-calendarweek",
"Repository": "https://edugit.org/AlekSIS/libs/python-calendarweek"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "1eef7687a7cafed01cb211bcba3d579f0b624f65d93aeabb75b271b955a409d2",
"md5": "256349c1ff872d67eab977e0874cab03",
"sha256": "b9b55013ff0288275445c0cb546b6ceb9ed02874819f9649f78479e48cb30786"
},
"downloads": -1,
"filename": "calendarweek-0.6-py3-none-any.whl",
"has_sig": false,
"md5_digest": "256349c1ff872d67eab977e0874cab03",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.10,<4.0",
"size": 11059,
"upload_time": "2023-12-05T09:43:00",
"upload_time_iso_8601": "2023-12-05T09:43:00.419748Z",
"url": "https://files.pythonhosted.org/packages/1e/ef/7687a7cafed01cb211bcba3d579f0b624f65d93aeabb75b271b955a409d2/calendarweek-0.6-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "f46f40ae1080331ea03aff921b7c5c099b3acdc8261c21875402635742a7f5d8",
"md5": "23875c12f807d60a61c69f07ca768b88",
"sha256": "8df37a60efe7324a91c1c1520a8faf67d04c0ebe450317fda6124b58fb6f7e1e"
},
"downloads": -1,
"filename": "calendarweek-0.6.tar.gz",
"has_sig": false,
"md5_digest": "23875c12f807d60a61c69f07ca768b88",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.10,<4.0",
"size": 8791,
"upload_time": "2023-12-05T09:43:01",
"upload_time_iso_8601": "2023-12-05T09:43:01.688730Z",
"url": "https://files.pythonhosted.org/packages/f4/6f/40ae1080331ea03aff921b7c5c099b3acdc8261c21875402635742a7f5d8/calendarweek-0.6.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-12-05 09:43:01",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "calendarweek"
}