SimpleSLACalc


NameSimpleSLACalc JSON
Version 0.0.4 PyPI version JSON
download
home_pagehttps://github.com/exodusprime1337/SimpleSLACalc
SummaryA simple SLA Calculator
upload_time2023-10-19 21:49:00
maintainer
docs_urlNone
authorKenny Sambrook
requires_python>=3.10,<3.12
licenseThe Unlicense
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Simple SLA Calculator
A very simple and rudimentary SLA timeframe calculator. 

## Installation
```
pip install SimpleSLACalc
```
## Usage
To calculate an SLA you need to provide a minimum set of parameters. 
- start_time (datetime | pendulum.DateTime | str): Start of sla time calculation(IE: "2023-10-01") or a datetime object
- open_hour (int): Start of business hour(24h format)
- close_hour (int): End of business hour(24h format)
- time_zone (str): Timezone in which to process calculation
- sla_hours (Optional[int], optional): Provide hours to calculate SLA in hours. Defaults to None.
- sla_days (Optional[int], optional): Provide days to calculate SLA in days. Defaults to None.
- sla_weeks (Optional[int], optional): Provide weeks to calculate SLA in weeks. Defaults to None.

**NOTE: Only provide one sla_hours, sla_days, or sla_weeks. Do not combine**

Additionally you can provide a number of optional parameters to fine tune your SLA calculations. 
Most notable here is **skip_business_hours**. By default business hours are ignored. It will return only the raw SLA calculation including weekends, and holidays. To only calculate business hours SLA's, set to False.
- skip_business_hours (Optional[bool]): When True, skips business hours, and just calculates raw SLA. Defaults to True.
- excluded_dates (Optional[list[str]], optional): Provide a list of dates in string format(IE: ["2023-10-1", 2023-10-02"]). Defaults to None.
- holiday_country (Optional[str], optional): Two character country code for holiday parsing. Required for holiday date SLA exclusion. Defaults to None.
- holiday_state (Optional[str], optional): Optional two character state for holiday date SLA exclusion. Defaults to None.
- holiday_province (Optional[str], optional): Optional two character province for holiday date SLA exclusion. Defaults to None.
```
from SimpleSLACalc import SLACalculator

my_sla_cal = SLACalculator()
sla_values = my_sla_cal.calculate(
    start_time="2023-10-18 01:27",
    open_hour=9,
    close_hour=17,
    sla_hours=6,
    time_zone="America/Chicago",
    skip_business_hours=False
)

print(sla_values.sla_expiration_time)
```
The output of the above code snippet looks as follows.
```
❯ python tests/test.py
2023-10-18 15:00:00-05:00
```
The output object is a class object named SLAItem with a range of values available for use. It appears like this in code.
```
@dataclass(frozen=True, order=False)
class SLAItem:
    """Class based SLA results item for user return

    Returns:
        cls: Class Object populated with SLA results calculations
    """

    start_time: pendulum.DateTime
    open_time: pendulum.DateTime | None
    close_time: pendulum.DateTime | None
    sla_expiration_time: pendulum.DateTime

    def sla_exp_hour(self) -> int:
        return self.sla_expiration_time.hour

    def sla_exp_min(self) -> int:
        return self.sla_expiration_time.minute

    def sla_exp_day(self) -> int:
        return self.sla_expiration_time.day

    def sla_exp_date(self) -> pendulum.Date:
        return self.sla_expiration_time.date()

    def __repr__(self) -> str:
        return str(self.sla_expiration_time)
```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/exodusprime1337/SimpleSLACalc",
    "name": "SimpleSLACalc",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.10,<3.12",
    "maintainer_email": "",
    "keywords": "",
    "author": "Kenny Sambrook",
    "author_email": "Kenny Sambrook <kenny@krstek.com>",
    "download_url": "https://files.pythonhosted.org/packages/74/32/ed7ee194fc39fff3aec7a290df649fe5ee1a469a2a6444b4131af24bc6ac/SimpleSLACalc-0.0.4.tar.gz",
    "platform": null,
    "description": "# Simple SLA Calculator\nA very simple and rudimentary SLA timeframe calculator. \n\n## Installation\n```\npip install SimpleSLACalc\n```\n## Usage\nTo calculate an SLA you need to provide a minimum set of parameters. \n- start_time (datetime | pendulum.DateTime | str): Start of sla time calculation(IE: \"2023-10-01\") or a datetime object\n- open_hour (int): Start of business hour(24h format)\n- close_hour (int): End of business hour(24h format)\n- time_zone (str): Timezone in which to process calculation\n- sla_hours (Optional[int], optional): Provide hours to calculate SLA in hours. Defaults to None.\n- sla_days (Optional[int], optional): Provide days to calculate SLA in days. Defaults to None.\n- sla_weeks (Optional[int], optional): Provide weeks to calculate SLA in weeks. Defaults to None.\n\n**NOTE: Only provide one sla_hours, sla_days, or sla_weeks. Do not combine**\n\nAdditionally you can provide a number of optional parameters to fine tune your SLA calculations. \nMost notable here is **skip_business_hours**. By default business hours are ignored. It will return only the raw SLA calculation including weekends, and holidays. To only calculate business hours SLA's, set to False.\n- skip_business_hours (Optional[bool]): When True, skips business hours, and just calculates raw SLA. Defaults to True.\n- excluded_dates (Optional[list[str]], optional): Provide a list of dates in string format(IE: [\"2023-10-1\", 2023-10-02\"]). Defaults to None.\n- holiday_country (Optional[str], optional): Two character country code for holiday parsing. Required for holiday date SLA exclusion. Defaults to None.\n- holiday_state (Optional[str], optional): Optional two character state for holiday date SLA exclusion. Defaults to None.\n- holiday_province (Optional[str], optional): Optional two character province for holiday date SLA exclusion. Defaults to None.\n```\nfrom SimpleSLACalc import SLACalculator\n\nmy_sla_cal = SLACalculator()\nsla_values = my_sla_cal.calculate(\n    start_time=\"2023-10-18 01:27\",\n    open_hour=9,\n    close_hour=17,\n    sla_hours=6,\n    time_zone=\"America/Chicago\",\n    skip_business_hours=False\n)\n\nprint(sla_values.sla_expiration_time)\n```\nThe output of the above code snippet looks as follows.\n```\n\u276f python tests/test.py\n2023-10-18 15:00:00-05:00\n```\nThe output object is a class object named SLAItem with a range of values available for use. It appears like this in code.\n```\n@dataclass(frozen=True, order=False)\nclass SLAItem:\n    \"\"\"Class based SLA results item for user return\n\n    Returns:\n        cls: Class Object populated with SLA results calculations\n    \"\"\"\n\n    start_time: pendulum.DateTime\n    open_time: pendulum.DateTime | None\n    close_time: pendulum.DateTime | None\n    sla_expiration_time: pendulum.DateTime\n\n    def sla_exp_hour(self) -> int:\n        return self.sla_expiration_time.hour\n\n    def sla_exp_min(self) -> int:\n        return self.sla_expiration_time.minute\n\n    def sla_exp_day(self) -> int:\n        return self.sla_expiration_time.day\n\n    def sla_exp_date(self) -> pendulum.Date:\n        return self.sla_expiration_time.date()\n\n    def __repr__(self) -> str:\n        return str(self.sla_expiration_time)\n```\n",
    "bugtrack_url": null,
    "license": "The Unlicense",
    "summary": "A simple SLA Calculator",
    "version": "0.0.4",
    "project_urls": {
        "Bug Tracker": "https://github.com/exodusprime1337/SimpleSLACalc/issues",
        "Homepage": "https://github.com/exodusprime1337/SimpleSLACalc"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "668155707e456594607b341e611e3f98b33a1c2735bf8dbf388aa2a34f482f6a",
                "md5": "75fe536320b113599ad242642ed7ad87",
                "sha256": "dc829f8d85ee0eecfe3a78ed9464dc732438dd2a50ebd1f1573173ba5698422e"
            },
            "downloads": -1,
            "filename": "SimpleSLACalc-0.0.4-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "75fe536320b113599ad242642ed7ad87",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10,<3.12",
            "size": 7807,
            "upload_time": "2023-10-19T21:48:59",
            "upload_time_iso_8601": "2023-10-19T21:48:59.257145Z",
            "url": "https://files.pythonhosted.org/packages/66/81/55707e456594607b341e611e3f98b33a1c2735bf8dbf388aa2a34f482f6a/SimpleSLACalc-0.0.4-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "7432ed7ee194fc39fff3aec7a290df649fe5ee1a469a2a6444b4131af24bc6ac",
                "md5": "87b2d8f8678274f4738855cf6e8690c6",
                "sha256": "fe859fd1a8a93852ec51ebfffd7aa8011e95637f0925b9132fb85e2ef463e8d3"
            },
            "downloads": -1,
            "filename": "SimpleSLACalc-0.0.4.tar.gz",
            "has_sig": false,
            "md5_digest": "87b2d8f8678274f4738855cf6e8690c6",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10,<3.12",
            "size": 7720,
            "upload_time": "2023-10-19T21:49:00",
            "upload_time_iso_8601": "2023-10-19T21:49:00.955461Z",
            "url": "https://files.pythonhosted.org/packages/74/32/ed7ee194fc39fff3aec7a290df649fe5ee1a469a2a6444b4131af24bc6ac/SimpleSLACalc-0.0.4.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-10-19 21:49:00",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "exodusprime1337",
    "github_project": "SimpleSLACalc",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [],
    "lcname": "simpleslacalc"
}
        
Elapsed time: 1.80336s