Type parameters

Hierarchy

  • WorkSchedule

Properties

cycle

Working cycle.

A cycle is an ordered list with day settings that is applied in a cycle to calendar days starting from the date it was applied to the working schedule. A weekly cycle is an array of exactly seven items with settings for each day of the week. The item with index 0 is Sunday; the item with index 1 is Monday and so on. Example of settings up the work schedule woth a weekly cycle: schdule " Five-day workweek".

const  workSchedule: WorkSchedule<'weekly'> = {
    type: 'weekly', 
    cycle: [] , 
}; 
for (let i = 0; i <= 6; i++ ) { 
    const daySettings:  CalendarDaySettings = { 
        startAt: new TTime(9, 0, 0, 0), // work  days starts at 9:00 
        endAt: new TTime(18, 0, 0, 0),  // work day  ends at18:00 
        breaks: [ // there is one break during the day from 12: 00 to 13:00 
            { 
                startAt: new TTime(12, 0, 0, 0),  
                endAt: new TTime(13, 0, 0, 0), 
                description:  'Lunch break', 
            }, 
        ]; 
        isWorkingDay: true,  //  is a working day 
        isHolidayDay: false, // is a non-working day
    };  
    switch (i) { 
        // sunday (day off) 
        case 0:  
            daySettings.isWorkingDay = false; 
             daySettings.isHolidayDay = false; 
            daySettings.description =  'Sunday'; 
            break; 
        // monday
        case 1:  
            daySettings.description = 'Monday'; 
            break;  
        // tuesday
        case 2: 
            daySettings.description =  'Tuesday'; 
            break; 
        // wednesday
        case 3:  
            daySettings.description = 'Wednesday'; 
            break;  
        // thursday
        case 4: 
            daySettings.description =  'Thursday'; 
            break; 
        // friday
        case 5:  
            daySettings.description = 'Friday'; 
            break;  
        // saturday(day off) 
        case 6: 
             daySettings.isWorkingDay = false; 
            daySettings.isHolidayDay =  false; 
            daySettings.description = 'Saturday'; 
            break;  
        default: 
            throw new Error('incorrect day index'); 
     } 
    workSchedule.cycle.push(daySettings); 
} 

A custotm cycle can be an array of any number of items. The item with index 0 will contain the settings of the day that corresponds to the date that the shedule was applied. Such a cycle can be used, for example, to set up a "24 shift" schedule. Example of the "24 hours and 2 days off" shift. The shift starts at 7:00 a.m. and ends at 6:59 a.m. the next calendar day.

const workSchedule: WorkSchedule<'custom'> = {
    type: 'custom', 
     cycle: [], 
}; 
// the shift lasts for 24 hours (with a 30-minute break) and  takes up two calendar days 
workSchedule.cycle.push({ 
    startAt: new  TTime(7, 0, 0, 0),    // the work day starts at 7:00 
    endAt: new TTime( 23, 59, 59, 999), // the work day ends at 23:59 
    breaks: [ // there is  one break from 15:00 to 15:30 
        { 
            startAt: new TTime(15,  0, 0, 0), 
            endAt: new TTime(15, 30, 0, 0), 
        }, 
    ],  
    isWorkingDay: true,  /is a working day 
    isHolidayDay: false, // is  a non-working day 
}); 
workSchedule.cycle.push({ 
    startAt: new TTime(0,  0, 0, 0),   // work day starts at 00:00 
    endAt: new TTime(6, 59, 59, 999) , // work day ends at 06:59 
    isWorkingDay: true,  // is a working day  
    isHolidayDay: false, // is not a bank holiday 
}); 
// settings of the  day off 
workSchedule.cycle.push({ 
    startAt: new TTime(0, 0, 0, 0),    //  day off starts at 00:00 
    endAt: new TTime(23, 59, 59, 999), // day off  ends at 23:59 
    isWorkingDay: false, // is not a working day 
     isHolidayDay: false, // is not a bank holiday 
}); 

Optional defaultDaySettings

defaultDaySettings: CalendarDaySettings

Standard working day settings.

The field is used to configure the settings of a regular working day. The fiels is created with the following default settings:

{
      startAt: new TTime(9, 0, 0, 0),    // Working day starts at 9:00 
     endAt:  new TTime(18, 0, 0, 0), // Working day ends at 18:00 
     breaks: [ //  During the working day there is one break from 12:00 to 13:00 
         {  
             startAt: new TTime(12, 0, 0, 0), 
             endAt: new  TTime(13, 30, 0, 0), 
         }, 
     ], 
     isWorkingDay: true,  //  This is a work day 
     isHolidayDay: false, // This is not a non-working  day 
} 

Note: The field is always filled in. This field is a non- required one for reverse compatibility.

type

type: T

Type of work schedule: weekly — weekly, custom — custom.