reported in GMT (you may assume this as UTC) to different local times.
Further I have to consider the daylight savings settings applicable at
that time. It seems this is very difficult in c++ since the timezone
information is taken from the environment variable and I cannot find a
thread safe way to set the environment variables.
Is there any way of getting date time converted to local time by
specifying the GMT and the timezone ?
something like convert_to_local(tm *pTime, const char *TZ)
As far as I know, this is not possible with "standard" C++. I need to
do this (I need to calculate some future local dates for time zones
other than one I am running on), and I use system-provided information
(in my case, Windows). Time zones are less of a problem, but daylight
saving time is a massive PITA, because the way it's computed is
__utterly__ crazy (but unfortunately necessary).
In Windows, DST switch is explainedin terms of "first/last X in Y"
where X is random day of week, Y is random month. According to
information found in Windows, some time zones (Egypt, IIRC), do DST
switch one second before midnight, and there are other sorts of crazy
dates/hours.
Then, with later system versions (Vista+), DST switch is year-
dependent, which only adds to confusion, and in my case simply makes
me aware that I just can't calculate my dates correctly, cause, what's
to prevent authorities to change DST switch moment at any time in
future and invalidate my calculation based on when I think DST switch
shall occur). Therefore, I put up a warning to users about that.
I already feel sorry for you (or, if there is some comprehensive time
library I know not about, perhaps not).
Goran.
Not only that - you also need knowledge about leap-seconds.