Created
July 25, 2018 23:02
-
-
Save echohes/f32ed9204018f8266f48e05f7c24df15 to your computer and use it in GitHub Desktop.
Get iterator and number for the range of available timeszone relative to the current time.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function tz_calculate(crt,start_time,end_time) | |
--[[ The function receives the current time, the start time and the end time. | |
Counts the total time of work "job_time" and the difference between the end of work and the current time "calc". | |
Compares calc and job_time | |
If calc is less than or equal to job_time, then the iterator LE (<=) and the calc result are selected to select the taason band. | |
If job_time is greater than calc, then the GE iterator (> =) is selected, and the timezone is calculated as the difference (calc - job_time) | |
--]] | |
job_time = (end_time - start_time) | |
calc = (end_time - crt) | |
if (calc <= job_time) then | |
return {tonumber(calc),"LE"} | |
elseif (calc > job_time) then | |
return {tonumber(calc - job_time),"GE"} | |
else | |
return nil | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
When accessing the function, we get an iterator for searching in the tarantool db and data for the search index.
EXAMPLE:
tz_calculate (7,9,21) (the current time is 7 am, and we need a range of time zones available from 9 to 21 local time)
result - {2, GE}
We are looking for time zones >= 2