! Речь идет именно о суточном интервале времени, т.к. если интервал будет больше функция работает не корректно ибо не использует EpochTime.
Поскольку надоело писать один и тот же кусок скрипта, да ещё переодически где-то ошибаться в нём написал такую функцию.
Код: Выделить всё
#----------------------------------------------------------------------
# FunctionRangeTime by Sertik 04/12/2020
#----------------------------------------------------------------------
# the specified time range must not exceed 24 hours !
# the function does not work correctly if parameters of a non-temporary type are specified
# usage [$FuncRangeTime "start time" "end time"] compares an occurrence in the current system time range
# usage [$FuncRangeTime "start time" "end time" "time"] calculates the occurrence of the specified time range
# example :log info [$FuncRangeTime "20:00:00" "10:00:00" "05:00:00"]
# answer function:
# "RANGE" - if the time is in the range
# "MISMATCH" - if the time is not in the range
# "EMPTY" - if a zero-length range is specified
global FuncRangeTime do={
:local TimeSet
:local FlagOn 0
:local answer
:if ([:len $0]!=0) do={
:if (([:typeof $1]!="nothing") and ([:typeof $2]!="nothing")) do={
:if ([:len $3]=0) do={:set TimeSet [/system clock get time]} else={:set TimeSet $3}
:if ($1=$2) do={:set $FlagOn 2}
:if ($1<$2) do={:if (($1<$TimeSet) && ($TimeSet<$2)) do={:set $FlagOn 1}}
:if ($1>$2) do={:if (($1<$TimeSet) && ($TimeSet<"23:59:59")) do={:set $FlagOn 1}}
:if ($1>$2) do={:if (("00:00:00"<=$TimeSet) && ($TimeSet>$1)) do={:set $FlagOn 1}}
:if ($1>$2) do={:if (("23:59:59">$TimeSet) && ($TimeSet<$2)) do={:set $FlagOn 1}}
if ($FlagOn=1) do={:set answer "RANGE"}
if ($FlagOn=0) do={:set answer "MISMATCH"}
if ($FlagOn=2) do={:set answer "EMPTY"}
:return $answer} else={:set answer "ERROR"; :log error ("Ошибка в параметре функции "."$[:pick $0 1 [:len $0]]"); :return $answer}
}
}
# Examles used:
#:log info [$FuncRangeTime "17:00:00" "07:00:00" "23:00:00"]
# :log info [$FuncRangeTime "17:00:00" "07:00:00" "23:00:00"]
# :log info [$FuncRangeTime "17:00:00" "07:00:00"]
# :log info [$FuncRangeTime "17:00:00"]