Re: make time calculations timezone independent (and thus more portable) (#1337)

ylfingr <[email protected]>
Newsgroups gmane.network.nagios.devel
Message-ID <monitoring-plugins/monitoring-plugins/pull/1337/[email protected]>
I'm not quite sure why there's no timezone mentioned in my outputs. I've
tried various settings (e.g. LANG=de_DE vs LANG=C), but there's never any
timezone indicator in the outputs. But this seems to be an issue on my
system.

Nevertheless, for the sake of argument, let's assume there's a timezone
indicator in the output. As you can see from your outputs, you'll never get
the expiration time of **02:00:00 PM CEST** / **14:00:00**, which would be
the correct time representation in the case of TZ=Europe/Berlin.

And as you can see in my last patch, the variable TZ is being cleared /
unset. Since the check uses "%c" in strftime, the user can still choose his
preferred TZ-settings.

At last, I have found a more verbose example:

## current behavior
```shell
TZ=UTC ./check_http -v -p443 -H github.com  -C 7,3 --sni
OK - Certificate 'github.com' will expire on Tue Apr 12 12:00:00 2016.
```
```shell
TZ=PST8PDT ./check_http -v -p443 -H github.com	-C 7,3 --sni
OK - Certificate 'github.com' will expire on Tue Apr 12 13:00:00 2016.
```

## new behavior
```shell
TZ=PST8PDT ./check_http -v -p443 -H github.com	-C 7,3 --sni
OK - Certificate 'github.com' will expire on Tue Apr 12 05:00:00 2016.
```

Since PST8PDT is UTC-8, the second output would be correct.



-- 
Reply to this email on GitHub:
https://github.com/monitoring-plugins/monitoring-plugins/pull/1337#issuecomment-95497698
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.