toRawWorkingInterval

Looking for the documentation on the newest versions of SIL Engine and the Simple Issue Language for Jira 8 for Server/Data Center? Click here !

Availability

This routine is available starting with SIL Engine™ 2.5.

Syntax

 toRawWorkingInterval (interval, [workingHours/day]);

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

Parameter name

Type

Required

Description

interval

interval

Yes

Specifies a date interval that will be converted from 24 hours/day to working hours/day.

formatnumberNoSpecifies the number of working hours per day the interval will be converted to. The default number is 8, if another number isn't specified.

Return type

interval

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

Example

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