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

ylfingr notifications at github.com
Thu Apr 23 11:01:10 CEST 2015


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.monitoring-plugins.org/archive/devel/attachments/20150423/c3b75f4f/attachment.html>


More information about the Devel mailing list