On Fri, 13 Jul 2007, Roland Mainz wrote:

> Frank Hofmann wrote:
>> On Wed, 4 Jul 2007, Frank Hofmann wrote:
>>> I wonder what is the simplest way to validate, from a C program, whether a
>>> given string can be successfully parsed as TZ (timezone) environment
>>> variable.
[ ... ]
> What about checking whether the TZ value has a subdir in
> /usr/share/lib/zoneinfo/ ?

That doesn't allow to test for "direct" specifications according to 
environ(5),

      TZ

          Timezone information. The contents of  this  environment
          variable   are   used   by   the   functions  ctime(3C),
          localtime(3C), strftime(3C), and mktime(3C) to  override
          the default timezone. The value of TZ has one of the two
          formats (spaces inserted for clarity):

            :characters

          or

            std offset dst offset, rule

          If TZ is of the first format  (that  is,  if  the  first
          character is a colon (:)), or if TZ is not of the second
          format, then TZ designates a path to a timezone database
          file  relative  to  /usr/share/lib/zoneinfo/, ignoring a
          leading colon if one exists.

          Otherwise, TZ is of the second form, which when expanded
          is as follows:

            stdoffset[dst[offset][,start[/time],end[/time]]]

          [ ... blah blubb very very gory details  follow ... ]

I.e. you can say something like:

        GMT1GMT2,90/02:00:00,304/02:00:00

to get central european time (not sure if I get start/end correct there).

Not that anyone really uses this ... not that I've seen anyway. Maybe 
that's why noone bothers about being able to verify such a setting. 
Olson's files are bliss :)

FrankH.

>
> ----
>
> Bye,
> Roland
>
> P.S.: Is there any (POSIX) API to list all supported timezones ?

Given that the above 'handcrafted' syntax allows you to specify anything 
(like, time changing from GMT+5 to GMT-10 on January, 17th, 04:55:23, and 
changing back on January, 29th, 23:01:03) for the rules, I don't think 
there actually can be such an API. Even for the "named" TZs, it's a 
problem as politicians change these at whim, see last year's flurry of 
timezone patches ...

FrankH.

>
> --
>  __ .  . __
> (o.\ \/ /.o) [EMAIL PROTECTED]
>  \__\/\/__/  MPEG specialist, C&&JAVA&&Sun&&Unix programmer
>  /O /==\ O\  TEL +49 641 7950090
> (;O/ \/ \O;)
>
_______________________________________________
opensolaris-code mailing list
[email protected]
http://mail.opensolaris.org/mailman/listinfo/opensolaris-code

Reply via email to