Time Zone
Peter Gordon
peter at pg-consultants.com
Thu Jan 4 02:20:30 PST 2007
>From man tzset:
Note that the variable daylight does not indicate that daylight savings
time applies right now.
So, you could feed the time to strftime and find which tzname was in
use.
Peter
On Wed, 2007-01-03 at 16:31 +0530, Lloyd wrote:
> Thank you Peter, Your post could help me to find out this solution. (But
> I am not sure about its accuracy!)
>
> This code works on my Linux machine, I dont know what to do with Windows
>
> #include<stdio.h>
> #include<time.h>
> #include<stdlib.h>
> int main(int argc, char* argv[])
> {
> extern char* tzname[2];
> extern long timezone;
> extern int daylight;
> setenv("TZ",argv[1],1);
> tzset();
> printf("%s\n%s\n%ld\n%d\n",tzname[0],tzname[1],timezone,daylight);
> return 0;
> }
>
> The results are
>
> Israel-> -7200 (-2hrs)
> NZ-> -43200 (-12) ;the result varies from your result
> Asia/Omsk-> -21600 (-6)
>
> Any suggestions?
>
> Regards,
> Lloyd
>
> On Wed, 2007-01-03 at 10:14 +0200, Peter Gordon wrote:
> > Details are in the manual for "date" and works for Linux
> >
> > Examples:
> > # TZ=NZ date '+%z'
> > +1300
> >
> > #TZ=Israel date '+%z'
> > +0200
> >
> > #TZ=Poland date '+%z'
> > +0100
> >
> > #TZ=Asia/Omsk date '+%z'
> > +0600
> >
> > Peter
> >
> > On Wed, 2007-01-03 at 11:24 +0530, Lloyd wrote:
> > > Thank you Paul. I saw that /usr/share/zoneinfo/zone.tab contains a list
> > > of time zones (This is what I want) like
> > >
> > > #country-
> > > #code coordinates TZ comments
> > > AD +4230+00131 Europe/Andorra
> > > AE +2518+05518 Asia/Dubai
> > > AF +3431+06912 Asia/Kabul
> > > AG +1703-06148 America/Antigua
> > > AI +1812-06304 America/Anguilla
> > > ....
> > > ....
> > >
> > > Now what I want is to convert this zone name to its corresponding offset
> > > from UTC.
> > >
> > > for example the offset for Asia/Calcutta from UTC is +530. How can get
> > > this +530 from Asia/Calcutta ? Any functions available for this?
> > >
> > > Regards,
> > > Lloyd
> > >
> > >
> > > On Tue, 2007-01-02 at 10:04 -0500, Paul Koning wrote:
> > > > >>>>> "lloyd" == lloyd <lloyd at cdactvm.in> writes:
> > > >
> > > > lloyd> Hi, I would like to read the time zone information from the
> > > > lloyd> user. Does anybody know an easy way for this? (Like one
> > > > lloyd> available in Windows and Linux ). I would like to read it from
> > > > lloyd> the bitmap (time zone map) as well as from a combo box. From
> > > > lloyd> where to I can get the time zone list? (I made a preliminary
> > > > lloyd> search in Internet)
> > > >
> > > > Timezone stuff is much harder than it seems. There are lots of
> > > > shorcuts that get you in trouble.
> > > >
> > > > On Unix systems, the full list of timezones is in the file system tree
> > > > at /usr/share/zoneinfo. And the timezone setting is a filename
> > > > relative to that subtree, for example US/Eastern or Asia/Calcutta. I
> > > > don't know where the map comes from.
> > > >
> > > > Windows seems to have a subset of the full set of zones. The problem
> > > > with a subset is that you end up not being able to represent the time
> > > > rules for a given country or part of a country. The offset from UTC
> > > > isn't the problem -- the problem is in the rules for when "daylight
> > > > savings time" ("summer time") starts and ends, or whether there is any
> > > > at all. There are only about 30 different UTC offsets in the world,
> > > > but several hundred summer time rulesets. That's why there are so
> > > > many entries under /usr/share/zoneinfo...
> > > >
> > > > If I had to do this, I'd either ask the user for a zone name, then
> > > > validate it against the zoneinfo tree, or I'd offer up a listbox
> > > > populated from a walk of that tree. Or perhaps a tree control?
> > > >
> > > > paul
> > > >
> > > >
> > > > ---------------------------------------------------------------------
> > > > To unsubscribe, e-mail: wx-users-unsubscribe at lists.wxwidgets.org
> > > > For additional commands, e-mail: wx-users-help at lists.wxwidgets.org
> > >
> > >
> > > ______________________________________
> > > Scanned and protected by Email scanner
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: wx-users-unsubscribe at lists.wxwidgets.org
> > > For additional commands, e-mail: wx-users-help at lists.wxwidgets.org
> > >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: wx-users-unsubscribe at lists.wxwidgets.org
> > For additional commands, e-mail: wx-users-help at lists.wxwidgets.org
>
>
> ______________________________________
> Scanned and protected by Email scanner
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: wx-users-unsubscribe at lists.wxwidgets.org
> For additional commands, e-mail: wx-users-help at lists.wxwidgets.org
>
More information about the wx-users
mailing list