PyShift Work Schedule
Work Schedule for Python
Public Member Functions | Public Attributes | List of all members
shift.Shift Class Reference

Class Shift is a scheduled working time period, and can include breaks. More...

Inheritance diagram for shift.Shift:

Public Member Functions

def __init__ (self, str name, str description, time start, timedelta duration)
 Construct a shift definition. More...
 
def addBreak (self, Break breakPeriod)
 Add a break period to this shift. More...
 
def removeBreak (self, Break breakPeriod)
 Remove a break from this shift. More...
 
Break createBreak (self, str name, str description, time startTime, timedelta duration)
 Create a break for this shift. More...
 
timedelta calculateWorkingTime (self, time fromTime, time toTime)
 Calculate the working time between the specified times of day. More...
 
bool spansMidnight (self)
 Check to see if this shift crosses midnight. More...
 
timedelta calculateTotalWorkingTime (self, time fromTime, time toTime, bool beforeMidnight)
 Calculate the working time between the specified times of day. More...
 
bool isInShift (self, time time)
 Test if the specified time falls within the shift. More...
 
timedelta calculateBreakTime (self)
 Calculate the total break time for the shift. More...
 
bool isWorkingPeriod (self)
 a shift is a working period
 
str __str__ (self)
 

Public Attributes

 breaks
 

Detailed Description

Class Shift is a scheduled working time period, and can include breaks.

Constructor & Destructor Documentation

◆ __init__()

def shift.Shift.__init__ (   self,
str  name,
str  description,
time  start,
timedelta  duration 
)

Construct a shift definition.

Parameters
nameName of shift
descriptionDescription of shift
startStarting time of day
durationDuration of shift

Member Function Documentation

◆ addBreak()

def shift.Shift.addBreak (   self,
Break  breakPeriod 
)

Add a break period to this shift.

Parameters
breakPeriodBreak

◆ calculateBreakTime()

timedelta shift.Shift.calculateBreakTime (   self)

Calculate the total break time for the shift.

Returns
duration of all breaks

◆ calculateTotalWorkingTime()

timedelta shift.Shift.calculateTotalWorkingTime (   self,
time  fromTime,
time  toTime,
bool  beforeMidnight 
)

Calculate the working time between the specified times of day.

Parameters
fromTimestarting time
toTimeEnding time
Returns
timedelta working time
Parameters
beforeMidnightIf true, and a shift spans midnight, calculate the time before midnight. Otherwise calculate the time after midnight.
Returns
timedelta working time

◆ calculateWorkingTime()

timedelta shift.Shift.calculateWorkingTime (   self,
time  fromTime,
time  toTime 
)

Calculate the working time between the specified times of day.

The shift must not span midnight.

Parameters
fromTimestarting time
toTimeEnding time
Returns
timedelta working time

◆ createBreak()

Break shift.Shift.createBreak (   self,
str  name,
str  description,
time  startTime,
timedelta  duration 
)

Create a break for this shift.

Parameters
nameName of break
descriptionDescription of break
startTimeStart of break
durationof break
Returns
Break

◆ isInShift()

bool shift.Shift.isInShift (   self,
time  time 
)

Test if the specified time falls within the shift.

Parameters
timeTime of day
Returns
True if the time is in the shift

◆ removeBreak()

def shift.Shift.removeBreak (   self,
Break  breakPeriod 
)

Remove a break from this shift.

Parameters
breakPeriodBreak

◆ spansMidnight()

bool shift.Shift.spansMidnight (   self)

Check to see if this shift crosses midnight.

Returns
True if the shift extends over midnight, otherwise False

The documentation for this class was generated from the following file: