ge*************@yahoo.com wrote:
Hi all,
Why doesn't _tzset return an error when the TZ environment
variable does not contain a valid timezone?
Other question: how to check the timezone is a valid one?
Thanks for all answers.
On unix/linux, see:
man tzset
Here's a quote from the man page:
<quote>
Conforming to: SVID 3, POSIX, 4.3BSD
#include <time.h>
void tzset (void);
extern char *tzname[2];
extern long timezone;
extern int daylight;
The tzset() function initializes the tzname variable from the TZ
environment variable. This function is automatically called by the other
time conversion functions that depend on the time zone. In a SysV-like
environment it will also set the variables timezone (seconds West of
GMT) and daylight (0 if this time zone does not have any daylight
savings time rules, nonzero if there is a time during the year when
daylight savings time applies).
If the TZ variable does not appear in the environment, the tzname
variable is initialized with the best approximation of local wall clock
time, as specified by the tzfile(5)-format file localtime found in the
system timezone directory (see below). (One also often sees
/etc/localtime used here, a symlink to the right file in the system
timezone directory.)
If the TZ variable does appear in the environment but its value is
empty or its value cannot be interpreted using any of the formats
specified below, Coordinated Universal Time (UTC) is used.
</quote>
Larry