03.08.2019, 18:22
Good companions, thanks for reading this thread. This is to tell you that I have one function per event which calls a user library. The idea is that by means of a button you can complete the fields of a date and a time variable based on previously established parameters, so that if it was set to "dia_tiem1" in 1 and "hor_tiem1" in 13 : 00: 00, automatically the value of 13:00:00 will be written in the "hour_checkout" variable and in the "day_checkout" variable the day following the current date will be written. The problem occurs is when the end of the month arrives, the ideal is that when executing the button on day 31 in the variable "dia_checkout" change the month and becomes September 1 for example, but it happens that it does not exceed 31 And neither does the month change. I imagine that this same problem I will have when it is December 31, the ideal would be that in the variable "dia_checkout" becomes January 1 of the following year, but this will not happen. I abbreviate the code that works for me as long as it is not 31 of the month and of which I have doubts about its behavior on the 30th and in February which has 28 days and 29 when it is leap. Thank you and I am attentive to your comments.
Code:
function perfil_fecha(obj_perf,hora_checkout,dia_checkout,dia_tiem1,hor_tiem1,dia_tiem2,hor_tiem2,dia_tiem3,hor_tiem3)
local hor_dia = os.date('*t')
if (obj_perf==1) then
set_dia=hor_dia.day+dia_tiem1
date_obj = {
day = set_dia,
month = hor_dia.month,
year = hor_dia.year,
}
log(date_obj)
grp.write(dia_checkout, date_obj)
grp.write(hora_checkout, hor_tiem1)
elseif (othercondition) then
dosomethingelse()
end
end