PyShift Work Schedule
Work Schedule for Python
Loading...
Searching...
No Matches
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

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

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()

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()

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: