I will be receiving data logs from several places across the world which I wish to process and present in the appropriate local timezone. Since the event times are in UTC I need a function to convert UTC to time in the appropriate timezone. I have tried:
function lt = mylocaltime(EventSecondsSinceEpoch, timezonestring)
setenv('tz','EST5EDT,M3.2.0/02:00:00,M11.1.0')
lt = localtime(EventSecondsSinceEpoch)
setenv('tz','')
endfunction
but (at least on windows 10 with Octave 4.4.1) this does not work. This however does work:
function lt = mylocaltime(EventSecondsSinceEpoch, timezonestring)
setenv('tz','EST5EDT,M3.2.0/02:00:00,M11.1.0')
pause(1)
lt = localtime(EventSecondsSinceEpoch)
setenv('tz','')
endfunction
Unfortunately as well as taking a second for a microsecond's worth of computation it causes unacceptable secondary effects on Octave itself, such as any file open in the Octave editor being reported as out of date.
Is there another way to implement
mylocaltime() in Octave without recoding from scratch the logic needed to process a timezone string?
Cheers... Ian