Goulib.workdays module

WorkCalendar class with datetime operations on working hours, handling holidays merges and improves BusinessHours and workdays packages

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

Bases: object

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
__class__

alias of type

__delattr__

Implement delattr(self, name).

__dir__() → list

default dir() implementation

__eq__

Return self==value.

__format__()

default object formatter

__ge__

Return self>=value.

__getattribute__

Return getattr(self, name).

__gt__

Return self>value.

__hash__

Return hash(self).

__le__

Return self<=value.

__lt__

Return self<value.

__ne__

Return self!=value.

__new__()

Create and return a new object. See help(type) for accurate signature.

__reduce__()

helper for pickle

__reduce_ex__()

helper for pickle

__repr__

Return repr(self).

__setattr__

Implement setattr(self, name, value).

__sizeof__() → int

size of object in memory, in bytes

__str__

Return str(self).

Goulib.workdays.FullTime = <Goulib.workdays.WorkCalendar object>

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

Goulib.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.

Goulib.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