Business Calendar: Difference between revisions

From QPR ProcessAnalyzer Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 1: Line 1:
The business calendar defines a weekly calendar for office or factory hours, which is used in the duration calculations to determine the duration in terms of the office hours (instead of 24h/days).
The business calendar defines a weekly calendar for e.g. working/office/factory hours, which is used in the duration calculations to determine the duration where only the working hours have been taken into account (instead of 24h/days).


== Business Calendar ==
== Business Calendar Object ==
In the expression language, a business calendar is created using the '''BusinessCalendar''' function which takes the calendar definition as the following structure:
In the expression language, a business calendar is created using the '''BusinessCalendar''' function which takes the calendar definition as the following structure:
<pre>
<pre>
Line 21: Line 21:
The previous example defines the following weekly schedule: Monday 8-16, Tuesday 8-11 and 12-17, Wednesday 8-16, Thursday 8-16 and Friday 8-15. Note that there is no working time in Saturday and Sunday, because they are not defined in the calendar.
The previous example defines the following weekly schedule: Monday 8-16, Tuesday 8-11 and 12-17, Wednesday 8-16, Thursday 8-16 and Friday 8-15. Note that there is no working time in Saturday and Sunday, because they are not defined in the calendar.


The structure in the business calendar initialization has the following properties:
* '''weeklyWorkingHours''': Defines the weekly working calendar. The items in the array are individual working periods within each day. There can be several working periods in the same weekday. The '''weekDay''' is defined as a number between 0 (Sunday) and 6 (Saturday). The '''startHour''' and '''endHour''' needs to be between 0 and 24. If no weekly schedule is defined, 24h/days calendar is assumed.
* '''weeklyWorkingHours''': Defines the weekly working calendar. The items in the array are individual working periods within each day. There can be several working periods in the same weekday. The '''weekDay''' is defined as a number between 0 (Sunday) and 6 (Saturday). The '''startHour''' and '''endHour''' needs to be between 0 and 24. If no weekly schedule is defined, 24h/days calendar is assumed.
* '''exceptionDays''': All the dates, when there is not working time, e.g. holidays. Exception days are defined as a string array where each day is defined using format '''yyyy-MM-dd'''. Defining exception days is not mandatory for in the business calendar.
* '''exceptionDays''': All the dates, when there is not working time, e.g. holidays. Exception days are defined as a string array where each day is defined using format '''yyyy-MM-dd'''. Defining exception days is not mandatory for in the business calendar.

Revision as of 21:03, 1 December 2020

The business calendar defines a weekly calendar for e.g. working/office/factory hours, which is used in the duration calculations to determine the duration where only the working hours have been taken into account (instead of 24h/days).

Business Calendar Object

In the expression language, a business calendar is created using the BusinessCalendar function which takes the calendar definition as the following structure:

BusinessCalendar(
  #{
    "weeklyWorkingHours": [
      #{ "weekDay": 1, "startHour": 8, "endHour": 16 },
      #{ "weekDay": 2, "startHour": 8, "endHour": 11 },
      #{ "weekDay": 2, "startHour": 12, "endHour": 17 },
      #{ "weekDay": 3, "startHour": 8, "endHour": 16 },
      #{ "weekDay": 4, "startHour": 8, "endHour": 16 },
      #{ "weekDay": 5, "startHour": 8, "endHour": 15 }
    ],
    "exceptionDays": [ "2020-12-06", "2020-12-24", "2020-12-25", "2020-12-26", "2021-01-01", "2021-01-06" ]
  }
)

The previous example defines the following weekly schedule: Monday 8-16, Tuesday 8-11 and 12-17, Wednesday 8-16, Thursday 8-16 and Friday 8-15. Note that there is no working time in Saturday and Sunday, because they are not defined in the calendar.

The structure in the business calendar initialization has the following properties:

  • weeklyWorkingHours: Defines the weekly working calendar. The items in the array are individual working periods within each day. There can be several working periods in the same weekday. The weekDay is defined as a number between 0 (Sunday) and 6 (Saturday). The startHour and endHour needs to be between 0 and 24. If no weekly schedule is defined, 24h/days calendar is assumed.
  • exceptionDays: All the dates, when there is not working time, e.g. holidays. Exception days are defined as a string array where each day is defined using format yyyy-MM-dd. Defining exception days is not mandatory for in the business calendar.

Duration Calculation

Durations can be calculated by using the timeDiff function in the business calendar as follows:

let calendar = BusinessCalendar({ ... });
calendar.timeDiff(date1, date2);

Example:

let calendar = BusinessCalendar(
  #{
    "weeklyWorkingHours": [
      #{ "weekDay": 1, "startHour": 8, "endHour": 16 },
      #{ "weekDay": 2, "startHour": 8, "endHour": 11 },
      #{ "weekDay": 2, "startHour": 12, "endHour": 17 }
    ],
    "exceptionDays": [ "2020-12-06", "2020-12-24", "2020-12-25", "2020-12-26", "2021-01-01", "2021-01-06" ]
  }
)
calendar.timeDiff(DateTime(2020, 12, 1), DateTime(2021, 1, 1));