misc_functions
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revision | |||
misc_functions [2021/04/14 08:38] – atolstov | misc_functions [2021/04/14 08:42] (current) – atolstov | ||
---|---|---|---|
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.1618389500.txt.gz · Last modified: 2021/04/14 08:38 by atolstov