business-python
Advanced tools
@@ -37,1 +37,16 @@ working_days: | ||
| - December 28th, 2020 | ||
| # New Year's Day | ||
| - January 1st, 2021 | ||
| # Australia Day | ||
| - January 26th, 2021 | ||
| # Good Friday | ||
| - April 2nd, 2021 | ||
| # Easter Monday | ||
| - April 5th, 2021 | ||
| # ANZAC Day falls on a Sunday, so the holiday rolls over | ||
| - April 26th, 2021 | ||
| # Christmas Day falls on a Saturday, so the holiday rolls over | ||
| - December 27th, 2021 | ||
| # Boxing Day falls on a Sunday, so the holiday rolls over | ||
| - December 28th, 2021 |
@@ -50,2 +50,23 @@ working_days: | ||
| # New Year's Day | ||
| - January 1st, 2021 | ||
| # Day after New Year's Day falls on a Saturday, so the holiday rolls over | ||
| - January 4th, 2021 | ||
| # Waitangi Day falls on a Saturday, so the holiday rolls over | ||
| - February 8th, 2021 | ||
| # Good Friday | ||
| - April 2th, 2021 | ||
| # Easter Monday | ||
| - April 5th, 2021 | ||
| # ANZAC Day falls on a Sunday, so the holiday rolls over | ||
| - April 26th, 2021 | ||
| # Queen's Birthday | ||
| - June 7th, 2021 | ||
| # Labor Day | ||
| - October 25th, 2021 | ||
| # Christmas Day falls on a Saturday, so the holiday rolls over | ||
| - December 27th, 2021 | ||
| # Boxing daY falls on a Sunday, so the holiday rolls over | ||
| - December 28th, 2021 | ||
@@ -57,1 +57,51 @@ working_days: | ||
| - December 31st, 2020 | ||
| # New Years Day | ||
| - January 1st, 2021 | ||
| # Maunday Thursday | ||
| - April 1st, 2021 | ||
| # Good Friday | ||
| - April 2nd, 2021 | ||
| # Easter Monday | ||
| - April 5th, 2021 | ||
| # General Prayer Day | ||
| - April 30th, 2021 | ||
| # Ascension Day | ||
| - May 13th, 2021 | ||
| # Bank Holiday | ||
| - May 14th, 2021 | ||
| # Whit Monday | ||
| - May 24th, 2021 | ||
| # Christmas Eve Day | ||
| - December 24th, 2021 | ||
| # Christmas Day | ||
| - December 25th, 2021 | ||
| # Second Day of Christmas | ||
| - December 26th, 2021 | ||
| # New Year's Eve | ||
| - December 31st, 2021 | ||
| # New Years Day | ||
| - January 1st, 2022 | ||
| # Maunday Thursday | ||
| - April 14th, 2022 | ||
| # Good Friday | ||
| - April 15th, 2022 | ||
| # Easter Monday | ||
| - April 18th, 2022 | ||
| # General Prayer Day | ||
| - May 13th, 2022 | ||
| # Ascension Day | ||
| - May 26th, 2022 | ||
| # Bank Holiday | ||
| - May 27th, 2022 | ||
| # Whit Monday | ||
| - June 6th, 2022 | ||
| # Christmas Eve Day | ||
| - December 24th, 2022 | ||
| # Christmas Day | ||
| - December 25th, 2022 | ||
| # Second Day of Christmas | ||
| - December 26th, 2022 | ||
| # New Year's Eve | ||
| - December 31st, 2022 |
@@ -36,1 +36,20 @@ working_days: | ||
| - December 28th, 2020 | ||
| # New Year's Day | ||
| - January 1st, 2021 | ||
| # Good Friday | ||
| - April 2nd, 2021 | ||
| # Victoria Day | ||
| - May 24th, 2021 | ||
| # Canada Day | ||
| - July 1st, 2021 | ||
| # Labor Day | ||
| - September 6th, 2021 | ||
| # Thanksgiving Day | ||
| - October 11th, 2021 | ||
| # Remembrance Day | ||
| - November 11th, 2021 | ||
| # Christmas | ||
| - December 25th, 2021 | ||
| # Boxing Day | ||
| - December 26th, 2021 |
+4
-3
| Metadata-Version: 2.1 | ||
| Name: business-python | ||
| Version: 1.0.2 | ||
| Version: 1.0.3 | ||
| Summary: Date calculations based on business calendars. | ||
@@ -17,7 +17,8 @@ Home-page: https://github.com/gocardless/business-python | ||
| Classifier: Programming Language :: Python :: 3.8 | ||
| Classifier: Programming Language :: Python :: 3.9 | ||
| Classifier: Topic :: Office/Business :: Scheduling | ||
| Classifier: Topic :: Software Development :: Libraries :: Python Modules | ||
| Requires-Dist: importlib_metadata (>=1.6.0,<2.0.0); python_version < "3.8" | ||
| Requires-Dist: importlib_metadata (>=1.6.0,<3.0.0); python_version < "3.8" | ||
| Requires-Dist: python-dateutil (>=2.8.1,<3.0.0) | ||
| Requires-Dist: pyyaml (>=5.3.1,<6.0.0) | ||
| Requires-Dist: pyyaml (>=5.1.2,<6.0.0) | ||
| Project-URL: Repository, https://github.com/gocardless/business-python | ||
@@ -24,0 +25,0 @@ Description-Content-Type: text/markdown |
+9
-9
| [tool.poetry] | ||
| name = "business-python" | ||
| version = "1.0.2" | ||
| version = "1.0.3" | ||
| description = "Date calculations based on business calendars." | ||
@@ -27,14 +27,14 @@ authors = ["GoCardless <engineering@gocardless.com>"] | ||
| python = "^3.6" | ||
| importlib_metadata = { version = "^1.6.0", python = "<3.8" } | ||
| importlib_metadata = { version = ">=1.6.0,<3.0.0", python = "<3.8" } | ||
| python-dateutil = "^2.8.1" | ||
| pyyaml = "^5.3.1" | ||
| pyyaml = "^5.1.2" | ||
| [tool.poetry.dev-dependencies] | ||
| black = "^19.10b0" | ||
| flake8 = "^3.7.9" | ||
| flake8 = "^3.8.4" | ||
| flake8-docstrings = "^1.5.0" | ||
| flake8-isort = "^3.0.0" | ||
| flake8-isort = "^4.0.0" | ||
| isort = "^4.3.21" | ||
| mypy = "^0.770" | ||
| pytest = "^5.4.1" | ||
| mypy = ">=0.770,<1.0.0" | ||
| pytest = "^6.1.2" | ||
| pytest-cov = "^2.8.1" | ||
@@ -56,3 +56,3 @@ toml = "^0.10.0" | ||
| [build-system] | ||
| requires = ["poetry>=1.0", "pip>=20.0"] | ||
| build-backend = "poetry.masonry.api" | ||
| requires = ["poetry-core>=1.0.0"] | ||
| build-backend = "poetry.core.masonry.api" |
+3
-3
@@ -11,10 +11,10 @@ # -*- coding: utf-8 -*- | ||
| install_requires = \ | ||
| ['python-dateutil>=2.8.1,<3.0.0', 'pyyaml>=5.3.1,<6.0.0'] | ||
| ['python-dateutil>=2.8.1,<3.0.0', 'pyyaml>=5.1.2,<6.0.0'] | ||
| extras_require = \ | ||
| {':python_version < "3.8"': ['importlib_metadata>=1.6.0,<2.0.0']} | ||
| {':python_version < "3.8"': ['importlib_metadata>=1.6.0,<3.0.0']} | ||
| setup_kwargs = { | ||
| 'name': 'business-python', | ||
| 'version': '1.0.2', | ||
| 'version': '1.0.3', | ||
| 'description': 'Date calculations based on business calendars.', | ||
@@ -21,0 +21,0 @@ 'long_description': '# Business (Python)\n\n[](https://app.circleci.com/pipelines/github/gocardless/business-python) [](https://badge.fury.io/py/business-python)\n\nDate calculations based on business calendars. (Python 3.6+)\n\nPython implementation of https://github.com/gocardless/business\n\n## Documentation\n\nTo get business, simply:\n\n```bash\n$ pip install business-python\n```\n\n### Getting started\n\nGet started with business by creating an instance of the calendar class, passing in a hash that specifies which days of the week are considered working days, and which days are holidays.\n\n```python\nfrom business.calendar import Calendar\n\ncalendar = Calendar(\n working_days=["monday", "tuesday", "wednesday", "thursday", "friday"],\n # array items are either parseable date strings, or real datetime.date objects\n holidays=["January 1st, 2020", "April 10th, 2020"],\n extra_working_dates=[],\n)\n```\n\n`extra_working_dates` key makes the calendar to consider a weekend day as a working day.\n\nA few calendar configs are bundled with the package (see [business/data](<(business/data)>) for details). Load them by calling the `load` class method on `Calendar`.\n\n```python\ncalendar = Calendar.load("weekdays")\n```\n\nIf `working_days` is missing, then common default is used (mon-fri).\nIf `holidays` is missing, "no holidays" assumed.\nIf `extra_working_dates` is missing, then no changes in `working_days` will happen.\n\nElements of `holidays` and `extra_working_dates` may be either strings that `Calendar.parse_date()` can understand, or YYYY-MM-DD (which is considered as a Date by Python YAML itself).\n\n```yaml\nholidays:\n - 2017-01-08 # Same as January 8th, 2017\n```\n\nThe `load_cache` method allows a thread safe way to avoid reloading the same calendar multiple times, and provides a performant way to dynamically load calendars for different requests.\n\n```python\ncalendar = Calendar.load_cache("weekdays")\n```\n\n### Input data types\n\nThe `parse_date` method is used to process the input date(s) in each method and return a `datetime.date` object.\n\n```python\nCalendar.parse_date("2019-01-01")\n# => datetime.date(2019, 1, 1)\n```\n\nSupported data types are:\n\n- `datetime.date`\n- `datetime.datetime`\n- `pandas.Timestamp` (treated as `datetime.datetime`)\n- date string parseable by [`dateutil.parser.parse`](https://dateutil.readthedocs.io/en/stable/parser.html#dateutil.parser.parse)\n\n`numpy.datetime64` is not supported, but can be converted to `datetime.date`:\n\n```python\nnumpy.datetime64(\'2014-06-01T23:00:05.453000000\').astype(\'M8[D]\').astype(\'O\')\n# => datetime.date(2014, 6, 1)\n```\n\n### Checking for business days\n\nTo check whether a given date is a business day (falls on one of the specified working days or extra working dates, and is not a holiday), use the `is_business_day` method on `Calendar`.\n\n```python\ncalendar.is_business_day("Monday, 8 June 2020")\n# => true\ncalendar.is_business_day("Sunday, 7 June 2020")\n# => false\n```\n\n### Custom calendars\n\nTo use a calendar you\'ve written yourself, you need to add the directory it\'s stored in as an additional calendar load path:\n\n```python\nCalendar.additional_load_paths = [\'path/to/your/calendar/directory\']\n```\n\nYou can then load the calendar as normal.\n\n### Business day arithmetic\n\n> For our purposes, date-based calculations are sufficient. Supporting time-based calculations as well makes the code significantly more complex. We chose to avoid this extra complexity by sticking solely to date-based mathematics.\n\nThe `add_business_days` method is used to perform business day arithmetic on dates.\n\n```python\ninput_date = Calendar.parse_date("Thursday, 12 June 2014")\ncalendar.add_business_days(input_date, 4).strftime("%A, %d %B %Y")\n# => "Wednesday, 18 June 2014"\ncalendar.add_business_days(input_date, -4).strftime("%A, %d %B %Y")\n# => "Friday, 06 June 2014"\n```\n\nThe `roll_forward` and `roll_backward` methods snap a date to a nearby business day. If provided with a business day, they will return that date. Otherwise, they will advance (forward for `roll_forward` and backward for `roll_backward`) until a business day is found.\n\n```python\ninput_date = Calendar.parse_date("Saturday, 14 June 2014")\ncalendar.roll_forward(input_date).strftime("%A, %d %B %Y")\n# => "Monday, 16 June 2014"\ncalendar.roll_backward(input_date).strftime("%A, %d %B %Y")\n# => "Friday, 13 June 2014"\n```\n\nIn contrast, the `next_business_day` and `previous_business_day` methods will always move to a next or previous date until a business day is found, regardless if the input provided is a business day.\n\n```python\ninput_date = Calendar.parse_date("Monday, 9 June 2014")\ncalendar.roll_forward(input_date).strftime("%A, %d %B %Y")\n# => "Monday, 09 June 2014"\ncalendar.next_business_day(input_date).strftime("%A, %d %B %Y")\n# => "Tuesday, 10 June 2014"\ncalendar.previous_business_day(input_date).strftime("%A, %d %B %Y")\n# => "Friday, 06 June 2014"\n```\n\nTo count the number of business days between two dates, pass the dates to `business_days_between`. This method counts from start of the first date to start of the second date. So, assuming no holidays, there would be two business days between a Monday and a Wednesday.\n\n```python\nfrom datetime import timedelta\n\ninput_date = Calendar.parse_date("Saturday, 14 June 2014")\ncalendar.business_days_between(input_date, input_date + timedelta(days=7))\n# => 5\n```\n\nThe `get_business_day_of_month` method return the running total of business days for a given date in that month. This method counts the number of business days from the start of the first day of the month to the given input date.\n\n```python\ninput_date = Calendar.parse_date("Thursday, 12 June 2014")\ncalendar.get_business_day_of_month(input_date)\n# => 9\n```\n\n### Included Calendars\n\nWe include some calendar data with this package but give no guarantees of its accuracy. The calendars that we include are:\n\n- ACH (United States)\n- Bacs\n- Bankgirot\n- BECS (Australia)\n- BECSNZ (New Zealand)\n- PAD (Canada)\n- Betalingsservice\n- Target (SEPA)\n- TargetFrance (SEPA + French bank holidays)\n\n## License & Contributing\n\n- This is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).\n- Bug reports and pull requests are welcome on GitHub at https://github.com/gocardless/business-python.\n\nGoCardless ♥ open source. If you do too, come [join us](https://gocardless.com/about/jobs).\n', |
Alert delta unavailable
Currently unable to show alert delta for PyPI packages.
58652
4.53%