On HP-UX ia64, when I provide set timezone as, TZ=CET, it simply considers it as being the same as UTC. As per HP-UX documentation at link emphasis mine,
"TZ can be set using the format:
[:]STDoffset[DST[offset][,rule]]"
The offset here is mandatory and represents "the value that must be added to local time to arrive at Coordinated Universal Time (UTC)."
So, without offset, HP-UX considers the STD the same as UTC.
localtime() returning ambigious
Question
I wrote the below code and tested it out on different platforms. I got different results on HP-UX IA64,as compared to other platforms.
Code:
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main(void)
{
time_t t;
struct tm *gmt, *lat, ldummy;
tzset();
printf("Local timezone: TZ=%s\n\n", getenv("TZ"));
t = 1394881705;
lat = localtime(&t);
printf("Local time is : %s", asctime(lat));
gmt = gmtime(&t);
printf("GMT is : %s", asctime(gmt));
return 0;
}
OUTPUT:-
Linux
$ ./a.out
Local timezone: TZ=CET
Local time is : Sat Mar 15 12:08:25 2014
GMT is : Sat Mar 15 11:08:25 2014
SunOs
$ ./a.out
Local timezone: TZ=CET
Local time is : Sat Mar 15 12:08:25 2014
GMT is : Sat Mar 15 11:08:25 2014
AIX
$ ./a.out
Local timezone: TZ=CET
Local time is : Sat Mar 15 12:08:25 2014
GMT is : Sat Mar 15 11:08:25 2014
(This is where the problem is) HP-UX IA64
$ ./a.out
Local timezone: TZ=CET
Local time is : Sat Mar 15 11:08:25 2014
GMT is : Sat Mar 15 11:08:25 2014
I am trying to understand why the output is differing in case of HP-UZ IA64(Version is 11.31). I could not find any relevant documentation for this eccentric behaviour. Would someone help me with understanding this?
Solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow