I think the issue is just your parentheses () placement. If we look at this line:
elseif (p.hour+1>10) & (p.hour+1<20)
You only need the parentheses to be around p.hour and your +1 adjustment to the time. Putting it in it's own set of parentheses makes sure that this part is done first before the script checks if the number is in the correct range . So you could change that line to be like this instead:
((p.hour+1) >10) & ((p.hour+1) <20)
Hopefully that makes sense?
Optionally, another way to do this would be to modify what p.hour is at the beginning of your script like this:
p:"%p" parse "%e" format sys.now utc_offset:1 p.hour:24%utc_offset+p.hour
The first line is the same as what you have now.
The second line defines a new variable called utc_offset which I'm going to use to say how many hours off from utc your time zone is. (1)
And the third line sets p.hour to be p.hour plus your utc_offset. The 24% in this line keeps the result consistent with 24 hour time. So if the math it was doing for p.hour was 23+1 it would go back to 0 instead of up to 24.
If this version makes sense to you then you could put this at the beginning of your script and just refer to p.hour for the rest of it without needing to modify it again, because it's already been modified.