Simple SLA Calculator
Project description
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,
open_minute=0
close_hour=17,
close_minute=0,
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)
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file simpleslacalc-0.0.6.tar.gz
.
File metadata
- Download URL: simpleslacalc-0.0.6.tar.gz
- Upload date:
- Size: 7.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.5.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1bf81dfde23831d1bad406dd8b07ccee7bfa060cdde03d2159d0848e1fc954f5 |
|
MD5 | 4026efdfa27a00bb68cb1f63f971f95a |
|
BLAKE2b-256 | 77fbd48253a32764fee79e34e1bfdbdff666d520f8a4a769153dbf2a14f90d06 |
File details
Details for the file simpleslacalc-0.0.6-py3-none-any.whl
.
File metadata
- Download URL: simpleslacalc-0.0.6-py3-none-any.whl
- Upload date:
- Size: 7.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.5.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | af25037c751595fbd2749d3e45ad368eccde8dccbb4554b5bfd8a3a1ac14c6a3 |
|
MD5 | 6f0547c94fb206e9a8a80c382d5641c0 |
|
BLAKE2b-256 | 416de458fa1bf60780a5f67105d9e1561e0f8474cac342b80a38f72b64a832fb |