Place to put your Basic demos and examples

Moderator: Mmiscool

User avatar
By psc-esp8266
#47079 While having to recalcuate several variables with timezone information from external sources I tried to make up for the missing function statemtent:
Normally if you want to add a timezone offset you get into trouble around midnight. specially if you don't know if your offset is positive or negative. Your programm needs a few IF's to solve that. In basic that means one or more goto's and at least a gosub.
This sollution works a bit like a function and can be copied straight into the needed place:
Assume you have your time in variable 't' (Let t="01:00"), your timezone offset in stored in 'offset'. like Let offset=-2

now the following will add the timezone offset to your time string:
a = (offset+val(mid(t,1,2))+24)%24
t = right("0" & str(a),2) & mid(t,3,8)
Now 't' will hold "23:00".

Please note: Due to a watchdog bug it is unfortunately not possible (yet) to replace these two line with one combined function t = right("0" & str((offset+val(mid(t,1,2))+24)%24),2) & mid(t,3,8)