Hello all,
I'm having a problem where a script needs to calculate GMT time given local time. For 6 months, that's easy. The other 6 months, it's not, as I have to add an extra hour to allow for Daylight Saving. At the moment, I manually add and remove an offset but, for obvious reasons, I'd prefer to automate this.
I was surprised that I couldn't find much discussion on this. What I'm looking for is some way to determine what the current local offset from GMT is. There is talk of an environment variable, $TZ, that includes information on the application of the summer time shift, but I cannot see this variable anywhere on my RHEL or Ubuntu machines.
So, is there a nice easy way to work out my current offset and therefore modify the size of the GMT shift I need. I'm thinking of using a cron, triggered at 0400 six months a year, to create $TZ or similar, but that would be ugly and just plain wrong for up to a day if I need to reboot during the summer!
Thanks!