addBusinessHour
Table of Contents
Note: This task is applicable to all services except Zoho Creator
Overview
The addBusinessHour function adds/subtracts the specified business hours to/from the input dateTimeValue.
Note: It allows for defining weekends, holiday lists, and business hours
Return Type
Syntax
<variable> = <dateTimeValue>.addBusinessHour(<no_of_hours>, <weekends_list>, <holiday_list>, <business_hours>);
where,
Parameter | Data type | Description |
<variable> | DATE-TIME | Variable which will contain the returned date-time value after adding/subtracting the required number of hours. |
<dateTimeValue> | DATE-TIME/TEXT | The date-time value to which the required number of business hours will be added/subtracted. |
<no_of_hours> | NUMBER / DECIMAL | The number of business hours to be added to/ subtracted from the date-time value. Note:
|
<weekends_list> (optional) | COLLECTION (OF TEXT) | The list of weekends that will be considered while adding/ subtracting business hours. Note: By default, the weekends list is {Saturday, Sunday} |
<holidays_list> (optional) | COLLECTION (OF DATES) | The list of holidays that will be considered while adding/ subtracting business hours. Note: If no holidays are provided, any day (except weekends) will be considered a working day. |
<business_hours> (optional) | COLLECTION | The collection of business hours that will be considered while adding/ subtracting business hours. The format is {"start":<start_hour>, "end":<end_hour>} Note: By default, the business hours are between 9AM (9) and 5PM (17). The business hours are represented in 24 hour format only. |
Examples
The below example illustrates adding 2 business hours to the 1st of January 2020 at 4PM. It declares Saturday and Sunday as weekends. It also lists the 2nd and 3rd of January as holidays. The workday starts at 10 AM and ends at 5PM.
meeting_time = "1-Jan-2020 16:00:00".addBusinessHour(2, {"Saturday", "Sunday"}, {'2-Jan-2020','3-Jan-2020'}, {"start":"10","end":"17"}); // meeting_time gets the value '06-Jan-2020 11:00:00' assigned to it.
// When two hours are added to 01-Jan-2020 16:00:00, the task adds an hour which makes it 1-Jan-2020 17:00:00. Adding further would reach end of the day. Since the next two days are holidays and the two following are weekends, the next working day is identified as Monday. So, adding one hour to it, the required date is returned as 06-Jan-2020 11:00:00