There were already several posts asking for this. It may be useful as a starting pointYou want localtime 8:00 to 18:00. 10 hours per 24 hours. Keep that interval each day, set the rest to unknown or to zero. You want monday to friday. Keep that interval (which has undesired time removed already) and set the rest to unknown or to zero.
Remaining: office hours. The average computed may be too low. This will be the case if you used zero to mask out the other hours. Compensate by multiplying by 24/10 and by 7/5.
Without generating complete CDEFs, and without testing and debugging, I think the following should get you started:You will need to tweak the numbers 21000 and 28000 so that they match the beginning of saturday and the end of sunday. The numbers are no magic. Modulo 86400 gives the hour in a day, modulo 604800 gives the hour in a week. Weeks do not start on monday, they start on friday 00:00 UTC.Code: Select all
if (localtime more than 08:00 and less or equal to 18:00) { then use ds0 else use value zero } ds0_modified1=LTIME,86400,%,28801,64800,LIMIT,UN,0,ds0,IF if (localtime between saturday and sunday) { then use value zero else use outcome of previous CDEF } ds0_modified2=LTIME,604800,%,21000,28000,LIMIT,UN,ds0_modified1,0,IF
CDEF compiled should look likeMy office hours are 8h - 17h in this example (see digits 8 and 17).Code: Select all
CDEF:ds0_officehours=LTIME,604800,%,3600,47,*,3600,47,48, +,*,LIMIT,UN,LTIME,86400,%,3600,8,*,1,+,3600,17,*,LIMIT,UN,UNKN,ds0,IF,UNKN,IF
Instead of setting values outside office hours to 0 I set it to UNKN.
48 is the length in hours of the weekend beginning on Sat 0h.
One correction: The "week" begins on Thursday (1.1.1970), not on Friday. This is the reason for the 47 in the CDEF.
Reinhard