{"id":15495927,"url":"https://github.com/omenapps/django-calendardate","last_synced_at":"2025-04-15T14:46:26.720Z","repository":{"id":57419200,"uuid":"340908892","full_name":"OmenApps/django-calendardate","owner":"OmenApps","description":"A calendar model with date metadata for querying against.","archived":false,"fork":false,"pushed_at":"2025-03-25T13:50:07.000Z","size":31,"stargazers_count":18,"open_issues_count":0,"forks_count":4,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-04-06T23:17:41.354Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/OmenApps.png","metadata":{"files":{"readme":"README.rst","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-02-21T13:32:35.000Z","updated_at":"2025-04-03T21:46:24.000Z","dependencies_parsed_at":"2024-10-02T08:20:40.077Z","dependency_job_id":null,"html_url":"https://github.com/OmenApps/django-calendardate","commit_stats":{"total_commits":12,"total_committers":2,"mean_commits":6.0,"dds":0.08333333333333337,"last_synced_commit":"bdaef5c17d6e5c97f4062f2b95ced331ef20083c"},"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OmenApps%2Fdjango-calendardate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OmenApps%2Fdjango-calendardate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OmenApps%2Fdjango-calendardate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OmenApps%2Fdjango-calendardate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/OmenApps","download_url":"https://codeload.github.com/OmenApps/django-calendardate/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249093817,"owners_count":21211785,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-02T08:20:34.066Z","updated_at":"2025-04-15T14:46:26.694Z","avatar_url":"https://github.com/OmenApps.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"===================\ndjango-calendardate\n===================\n\n*A calendar model with date metadata for querying against.*\n\nSometimes it is useful to have a range of dates and associated metadata stored in the database, rather than calculating on-the-fly, particularly when creating reports based on quarters, fiscal years, etc. This is where django-calendardate comes in. Also known as a date dimension table or calendar table, the inspiration for this project comes from `this article \u003chttps://www.sqlshack.com/designing-a-calendar-table/\u003e`_.\n\ndjango-calendardate provides:\n\n* a model for storing metadata about a set of dates.\n* a management command for generating the metadata\n\n\nTHIS PROJECT IS PRE_RELEASE. It works, but is missing documentation and tests. Be cautious.\n\nUsage\n-----\n\nInstall using pip:\n\n    ``pip install django-calendardate``\n\nAdd to ``settings.INSTALLED_APPS``\n\nRun ``manage.py migrate``\n\nTo process a range of dates (ignoring any duplicates):\n\n    ``python manage.py process_dates 2021-01-01 2021-12-31``\n\n\nTo process a range of dates (overwriting any duplicates):\n\n    ``python manage.py process_dates 2021-01-01 2021-12-31 --force``\n\n\nOptional settings.py settings\n-----------------------------\n\nBy default, django-calendardate assumes a fiscal year starts in October. If your fiscal year begins on a different month, set ``FISCAL_YEAR_START_MONTH`` to the month number (1-indexed). For instance January would be 1).\n\n    ``FISCAL_YEAR_START_MONTH = 1``\n\n\nModel Fields\n------------\n\nEach of the following are automatically calculated and inserted into the model using the ``process_dates`` management command.\n\n    **calendar_date** (*DateField*)\n        The actual date object\n\n    **calendar_day** (*PositiveSmallIntegerField*)\n        Number from 1 through 31\n\n    **calendar_month** (*PositiveSmallIntegerField*)\n        Month number from 1-12\n\n    **calendar_year** (*PositiveSmallIntegerField*)\n        Current year, eg: 2017, 2025, 1984\n\n    **calendar_quarter** (*PositiveSmallIntegerField*)\n        1-4, indicates quarter within the current year\n\n    **fiscal_year** (*PositiveSmallIntegerField*)\n        Current fiscal year, eg: 2017, 2025, 1984\n\n    **fiscal_quarter** (*PositiveSmallIntegerField*)\n        1-4, indicates fiscal quarter within the current fiscal year\n\n    **day_of_week** (*PositiveSmallIntegerField*)\n        Monday is 0 and Sunday is 6\n\n    **day_of_isoweek** (*PositiveSmallIntegerField*)\n        Monday is 1 and Sunday is 7\n\n    **day_of_quarter** (*PositiveSmallIntegerField*)\n        Number from 1-92, indicates the day # in the current quarter\n\n    **day_of_year** (*PositiveSmallIntegerField*)\n        Number from 1-366\n\n    **week_of_month** (*PositiveSmallIntegerField*)\n        Number from 1-6, indicates the number of week within the current month\n\n    **week_of_year** (*PositiveSmallIntegerField*)\n        Number from 1-53, indicates the number of week within the current year\n\n    **isoweek_of_year** (*PositiveSmallIntegerField*)\n        Number from 1-53, indicates the number of isoweek within the current year\n\n    **is_weekday** (*BooleanField*)\n        True if Monday--\u003eFriday, False for Saturday/Sunday\n\n    **is_leap_year** (*BooleanField*)\n        True if current year is a leap year\n\n    **days_in_month** (*PositiveSmallIntegerField*)\n        Number of days in the current month\n\nModel Properties\n----------------\n\nEach of the following properties are provided for each date.\n\n    **get_day_name** (*property*)\n        returns a string with the name of the day for the given date (e.g.: \"Monday\")\n\n    **get_month_name** (*property*)\n        returns a string with the name of the month for the given date (e.g.: \"January\")\n\n    **get_month_abbreviated** (*property*)\n        returns a string with the abbreviated name of the month for the given date (e.g.: \"Jan\")\n\n\nQuick Example:\n--------------\n\nSay you have an Order model with a `order_date` field, and you want to query all of the orders that were placed in the third fiscal quarter of fiscal year 2021.\n\n.. code-block:: python\n\n    # Return list of  of dates in 3rd Qtr of FY21\n    third_fiscal_qtr_dates = CalendarDate.objects.filter(fiscal_year=2021, fiscal_quarter=3).values_list('calendar_date', flat=True)\n    \n    # Filter on those dates\n    third_qtr_orders = Order.objects.filter(order_date__in=third_fiscal_qtr_dates)\n\n\nTo Do\n-----\n\n1. Testing\n\n2. Better documentation\n\n3. Translations (strings already marked for translation)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fomenapps%2Fdjango-calendardate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fomenapps%2Fdjango-calendardate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fomenapps%2Fdjango-calendardate/lists"}