Time.WorkingTime (etl_core v0.1.55)
Module oriented to the calculation of working time, according to the business
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.
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:
- 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:
- 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:
- 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:
- {:ok, Integer (seconds)} | {:error, String}