Previous topic

tank

This Page

workdays

WorkCalendar class with datetime operations on working hours

class workdays.WorkCalendar(worktime=[datetime.time(0, 0), datetime.time(23, 59, 59, 999999)], parent=[], weekends=(5, 6), holidays=set([]))[source]

WorkCalendar class with datetime operations on working hours

__init__(worktime=[datetime.time(0, 0), datetime.time(23, 59, 59, 999999)], parent=[], weekends=(5, 6), holidays=set([]))[source]
start
end
setworktime(worktime)[source]
addholidays(days)[source]

add day(s) to to known holidays. dates with year==4 (to allow Feb 29th) apply every year note : holidays set may contain weekends too.

isworkday(day)[source]

@return True if day is a work day

isworktime(time)[source]

@return True if you’re supposed to work at that time

nextworkday(day)[source]

@return next work day

prevworkday(day)[source]

@return previous work day

range(start, end)[source]

range of workdays between start (included) and end (not included)

workdays(start_date, ndays)[source]

list of ndays workdays from start

workday(start_date, ndays)[source]

Same as Excel WORKDAY function. Returns a date that is the indicated number of working days before or after the starting date. Working days exclude weekends and any dates identified as holidays. Use WORKDAY to exclude weekends or holidays when you calculate invoice due dates, expected delivery times, or the number of days of work performed.

cast(time, retro=False)[source]

force time to be in workhours

worktime(day)[source]

@return interval of time worked a given day

workdatetime(day)[source]

@return interval of datetime worked a given day

diff(t1, t2)[source]

@return timedelta worktime between t1 and t2 (= t2-t1)

gethours(t1, t2)[source]

@return fractional work hours between t1 and t2 (= t2-t1)

plus(start, t)[source]

@return start time + t work time (positive or negative)

minus(start, t)[source]

@return start time - t work time (positive or negative)

networkdays(start_date, end_date)[source]

Same as Excel NETWORKDAYS function. Returns the number of whole working days between start_date and end_date (inclusive of both start_date and end_date). Working days exclude weekends and any dates identified in holidays. Use NETWORKDAYS to calculate employee benefits that accrue based on the number of days worked during a specific term

FRI = 4
MON = 0
SAT = 5
SUN = 6
THU = 3
TUE = 1
WED = 2
workdays.FullTime = <workdays.WorkCalendar instance at 0x04769EB8>

compatibility with http://pypi.python.org/pypi/BusinessHours

workdays.workday(start_date, ndays, holidays=[])[source]

Same as Excel WORKDAY function. Returns a date that is the indicated number of working days before or after the starting date. Working days exclude weekends and any dates identified as holidays. Use WORKDAY to exclude weekends or holidays when you calculate invoice due dates, expected delivery times, or the number of days of work performed.

workdays.networkdays(start_date, end_date, holidays=[])[source]

Same as Excel NETWORKDAYS function. Returns the number of whole working days between start_date and end_date (inclusive of both start_date and end_date). Working days exclude weekends and any dates identified in holidays. Use NETWORKDAYS to calculate employee benefits that accrue based on the number of days worked during a specific term

class workdays.TestCase(methodName='runTest')[source]

Bases: unittest.case.TestCase

Create an instance of the class that will use the named test method when executed. Raises a ValueError if the instance does not have a method with the specified name.

runTest()[source]