misc_functions
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
misc_functions [2021/04/14 08:34] – atolstov | misc_functions [2021/04/14 08:42] (current) – atolstov | ||
---|---|---|---|
Line 34: | Line 34: | ||
| | ||
end | end | ||
+ | -- Additional functions can be defined after or before main() loop | ||
function GetTimePrecise() | function GetTimePrecise() | ||
local start_time = GetTime(); | local start_time = GetTime(); | ||
Line 72: | Line 72: | ||
</ | </ | ||
+ | ==== IfInRangeHHMM ==== | ||
+ | <code lua IfInRangeHHMM> | ||
+ | function main (userId) | ||
+ | now = os.time() | ||
+ | | ||
+ | | ||
+ | working_time = ifInRangeHHMM(now, | ||
+ | | ||
+ | | ||
+ | TRACE(" | ||
+ | if working_time then | ||
+ | -- Add your code here | ||
+ | end | ||
+ | end | ||
+ | function ifInRangeHHMM(now, | ||
+ | -- проверяет текущее время на попадание в диапазон час минута | ||
+ | out = false | ||
+ | local cur_HH, cur_MM = tonumber(os.date(" | ||
+ | tonumber(os.date(" | ||
+ | |||
+ | -- TRACE(" | ||
+ | not_splitted_midnight_shift = start_hour < end_hour or start_hour == end_hour and start_min < end_min | ||
+ | if not_splitted_midnight_shift then | ||
+ | |||
+ | local after_start | ||
+ | local before_end = | ||
+ | -- TRACE(" | ||
+ | -- TRACE(" | ||
+ | | ||
+ | out = after_start and before_end | ||
+ | else | ||
+ | TRACE(" | ||
+ | out = ifInRangeHHMM(now, | ||
+ | end | ||
+ | | ||
+ | | ||
+ | return out | ||
+ | |||
+ | end | ||
+ | |||
+ | |||
+ | </ |
misc_functions.txt · Last modified: 2021/04/14 08:42 by atolstov