Metadata-Version: 2.1
Name: calc-work-hours
Version: 0.2024.1
Summary: Given two datetimes, calculate the working hours between them.
Author-email: Yosef HE <h7w8@qq.com>
License: MIT License
        
        Copyright (c) 2023 calc-work-hours Yosef HE
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
Project-URL: Homepage, https://github.com/williamxhero/work_hours
Keywords: work hour,workhour,working hour,workinghour,work day,workday,working day,workingday
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.11
Description-Content-Type: text/markdown
License-File: LICENSE

# Calc Work Hours
计算两个`DateTime`之间，工作时间的长度（小时）。这个工具最初是用来计算任务工时的。给定任务开始时间，任务结束时间，得出任务工时。会刨去中国的法定节假日及周末。因为中国假日每年发布一次，所以这个工具的第二位版本号就是最新支持年份，如：`v0.2023`就是已经更新到2023年节假日及调休。起始年份是2015年。早于2015年的日期，或者晚于版本号日期，只刨去周末。

Calculate the length of work hours between two `DateTime`s. This tool was originally used to calculate task hours. Given the task start time and the task end time, the task hours are calculated. It will exclude China's statutory holidays and weekends. Because China's holidays are released once a year, the second version number of this tool is the latest supported year, such as: `v0.2023` means that it has been updated to 2023 holidays and adjustments. The starting year is 2015. Dates earlier than 2015 or later then the version year will only exclude weekends.


## install
目前只支持 python 3.11 及更高：

Currently only supports python 3.11 and higher:

`pip311 install calc_work_hours`

## usage
```python
from datetime import datetime, time

from work_hours import WorkHours

wh = WorkHours()

#计算某天是否工作日 
# #Calculate whether a day is a working day
ret = wh.is_workday(datetime(2023, 10, 2))  
# 周一，但是 False
# Monday, but False
print(ret) 

ret = wh.is_workday(datetime(2023, 10, 7))
# 周六，但是 True
# Saturday, but True
print(ret) 

#计算两个日期之间的工作时间
#Calculate the working time between two dates
ret = wh.calc(datetime(2023, 9, 22, 1, 1, 1), datetime(2023, 10, 4, 18, 0, 0)) 
# 40 (hours)
print(ret) 

```
