Time.WorkingTime (etl_core v0.1.54)

Module oriented to the calculation of working time, according to the business

Link to this section Summary

Functions

Given a date, it returns the next date such that it is skilled in the defined working hours. Can return the same date.

Calculates the working time elapsed between two dates. Depending on the business, hours vary.

Link to this section Functions

Link to this function

convert_to_business_datetime(date, business, params, bool)

Given a date, it returns the next date such that it is skilled in the defined working hours. Can return the same date.

parameter

Parameter:

- date: DateTime. Date.

- business: Atom. Business.

- params: t. Auxiliary parameters.

- change_timezone: Boolean. Indicate if you have to change the dates to the time use defined in the configuration.

return

Return:

- DateTime
Link to this function

elapsed_time(start_date, end_date, business, params, change_timezone \\ true)

Calculates the working time elapsed between two dates. Depending on the business, hours vary.

To add a new business and its particular hours, you must:

1. Define a module with the name of the business.
2. Implement the Time.PWorkingTimeForBusiness protocol, to define particular hours. Use the following template:

```
define Time.PWorkingTimeForBusiness, for: Atom do
    def function_name(date, <business_name>) do
        ...
    end

    ...

end
```

parameter

Parameter:

- start_date: Timex.DateTime or String. Start date.

- end_date: Timex.DateTime or String. End date.

- business: Atom. Business.

- params: t. Auxiliary parameters.

- change_timezone: Boolean. Indicate if you have to change the dates to the time use defined in the configuration.

return

Return:

- {:ok, Integer (seconds)} | {:error, String}