PyShift Work Schedule
Work Schedule for Python
Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | List of all members
work_schedule.WorkSchedule Class Reference

Class WorkSchedule represents a named group of teams who collectively work one or more shifts with off-shift periods. More...

Inheritance diagram for work_schedule.WorkSchedule:

Public Member Functions

def __init__ (self, str name, str description)
 Construct a work schedule. More...
 
def deleteTeam (self, Team team)
 Remove this team from the schedule. More...
 
def deleteNonWorkingPeriod (self, NonWorkingPeriod period)
 Remove a non-working period from the schedule. More...
 
[ShiftInstance] getShiftInstancesForDay (self, date day)
 Get the list of shift instances for the specified date that start during that date. More...
 
[ShiftInstance] getShiftInstancesForTime (self, datetime dateTime)
 Get the list of shift instances for the specified date and time of day. More...
 
Team createTeam (self, str name, str description, Rotation rotation, time rotationStart)
 Create a team. More...
 
Shift createShift (self, str name, str description, time start, timedelta duration)
 Create a shift. More...
 
def deleteShift (self, Shift shift)
 Delete this shift. More...
 
NonWorkingPeriod createNonWorkingPeriod (self, str name, str description, datetime startDateTime, timedelta duration)
 Create a non-working period of time. More...
 
Rotation createRotation (self, str name, str description)
 Create a rotation. More...
 
timedelta getRotationDuration (self)
 Get total duration of rotations across all teams. More...
 
timedelta getRotationWorkingTime (self)
 Get the total working time for all team rotations. More...
 
timedelta calculateWorkingTime (self, datetime fromTime, datetime toTime)
 Calculate the scheduled working time between the specified dates and times of day. More...
 
timedelta calculateNonWorkingTime (self, datetime fromTime, datetime toTime)
 Calculate the non-working time between the specified dates and times of day. More...
 
def printShiftInstances (self, date start, date end)
 Print shift instances. More...
 
str __str__ (self)
 

Static Public Member Functions

time getPeriodKey (NonWorkingPeriod period)
 Get the key for sorting non-working periods
More...
 

Public Attributes

 teams
 
 shifts
 
 rotations
 
 nonWorkingPeriods
 

Static Public Attributes

 key
 

Detailed Description

Class WorkSchedule represents a named group of teams who collectively work one or more shifts with off-shift periods.

A work schedule can have periods of non-working time as well as breaks.

Constructor & Destructor Documentation

◆ __init__()

def work_schedule.WorkSchedule.__init__ (   self,
str  name,
str  description 
)

Construct a work schedule.

Parameters
nameSchedule name
descriptionSchedule description

Member Function Documentation

◆ calculateNonWorkingTime()

timedelta work_schedule.WorkSchedule.calculateNonWorkingTime (   self,
datetime  fromTime,
datetime  toTime 
)

Calculate the non-working time between the specified dates and times of day.

Parameters
fromTimeStarting date and time of day
toTimeEnding date and time of day
Returns
Non-working time duration

◆ calculateWorkingTime()

timedelta work_schedule.WorkSchedule.calculateWorkingTime (   self,
datetime  fromTime,
datetime  toTime 
)

Calculate the scheduled working time between the specified dates and times of day.

Non-working periods are removed.

Parameters
fromTimeStarting date and time of day
toTimeEnding date and time of day
Returns
Working time duration

◆ createNonWorkingPeriod()

NonWorkingPeriod work_schedule.WorkSchedule.createNonWorkingPeriod (   self,
str  name,
str  description,
datetime  startDateTime,
timedelta  duration 
)

Create a non-working period of time.

Parameters
nameName of period
descriptionDescription of period
startDateTimeStarting date and time of day
durationDuration of period
Returns
NonWorkingPeriod

◆ createRotation()

Rotation work_schedule.WorkSchedule.createRotation (   self,
str  name,
str  description 
)

Create a rotation.

Parameters
nameName of rotation
descriptionDescription of rotation
Returns
Rotation

◆ createShift()

Shift work_schedule.WorkSchedule.createShift (   self,
str  name,
str  description,
time  start,
timedelta  duration 
)

Create a shift.

Parameters
nameName of shift
descriptionDescription of shift
startstart time of day
durationduration of shift
Returns
Shift

◆ createTeam()

Team work_schedule.WorkSchedule.createTeam (   self,
str  name,
str  description,
Rotation  rotation,
time  rotationStart 
)

Create a team.

Parameters
nameName of team
descriptiondescription of team
rotationrotation
rotationStartStart of rotation
Returns
Team

◆ deleteNonWorkingPeriod()

def work_schedule.WorkSchedule.deleteNonWorkingPeriod (   self,
NonWorkingPeriod  period 
)

Remove a non-working period from the schedule.

Parameters
periodNonWorkingPeriod

◆ deleteShift()

def work_schedule.WorkSchedule.deleteShift (   self,
Shift  shift 
)

Delete this shift.

Parameters
shiftShift to delete

◆ deleteTeam()

def work_schedule.WorkSchedule.deleteTeam (   self,
Team  team 
)

Remove this team from the schedule.

Parameters
teamTeam

◆ getPeriodKey()

time work_schedule.WorkSchedule.getPeriodKey ( NonWorkingPeriod  period)
static

Get the key for sorting non-working periods

Parameters
periodNonWorkingPeriod
Returns
time key

◆ getRotationDuration()

timedelta work_schedule.WorkSchedule.getRotationDuration (   self)

Get total duration of rotations across all teams.

Returns
Duration of team rotations

◆ getRotationWorkingTime()

timedelta work_schedule.WorkSchedule.getRotationWorkingTime (   self)

Get the total working time for all team rotations.

Returns
sum of rotation working times

◆ getShiftInstancesForDay()

[ShiftInstance] work_schedule.WorkSchedule.getShiftInstancesForDay (   self,
date  day 
)

Get the list of shift instances for the specified date that start during that date.

Parameters
daydate
Returns
list of ShiftInstance

◆ getShiftInstancesForTime()

[ShiftInstance] work_schedule.WorkSchedule.getShiftInstancesForTime (   self,
datetime  dateTime 
)

Get the list of shift instances for the specified date and time of day.

Parameters
dateTimeDate and time of day
Returns
List of ShiftInstance

◆ printShiftInstances()

def work_schedule.WorkSchedule.printShiftInstances (   self,
date  start,
date  end 
)

Print shift instances.

Parameters
startStarting date
endEnding date

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