toRawWorkingInterval

Description

Returns a date interval converted to the specified number of hours per day. This routine re-writes a 24h day interval in an interval that is based on 8h (for instance). It is not sensitive for weekends, holidays, leave without pay, and so on. The result interval is converted using the workingHours/day parameter that is optional and is an integer between 1 and 24. This routine can be used to view how much hours can a user work during a week, for instance.

Parameters

Return Type

Interval

The return value represents the converted interval from the interval given as argument.

Examples

Example 1

Let us consider the following SIL code:

date begin = "2013-01-17T12:30:00"; date end = "2013-01-28T16:30:00"; return toRawWorkingInterval(end - begin, 6);

This will return "2d 22h" due to:

  1. The interval between begin date and end date is 11d 4h.

  2. If we convert a day from 24 hours to a 6 hour per day we will make the following computation: 11d * 6h + 4h = 66h + 4h = 70h that will be viewed as 2d 22h.

 

Example 2

By running this code:

date begin = "2013-01-17T02:30:00"; date end = "2013-01-28T16:30:00"; return toRawWorkingInterval(end - begin);

The result will return "4d" due to:

  1. The interval is "11d 12h" long.

  2. The conversion is based on this computation: 12d * 8h(default hours) = 96h that means "4d".

  3. This is done so because the number of hours in the 12th day of the interval exceeds the number of working hours per day (by default 8) and a new day is added.

 

See also