How to get timezone information

How to get timezone information

Post by Norman Blac » Tue, 02 May 2000 04:00:00



I am porting from Win32 and I am trying to found the timezone information.
Specifically the number of hours/minutes offset from UTC.

I found information that Posix requires the TZ environment variable but no
such environment variable exists on my system, Mandrake 7.0. I thought of
using gmtime and localtime and converting back to seconds and subtracting
but mktime does a UTC conversion.

I hope I do not have to do computation myself using gmtime and localtime. I
was hoping the system would have an API call to give me detailed information
as Win32 does.

--
Norman Black
Stony Brook Software
To reply via email reverse the identifiers in the domain.

 
 
 

How to get timezone information

Post by Paul Kimo » Tue, 02 May 2000 04:00:00



> I am porting from Win32 and I am trying to found the timezone information.
> Specifically the number of hours/minutes offset from UTC.

> I found information that Posix requires the TZ environment variable but no
> such environment variable exists on my system, Mandrake 7.0.

It doesn't?  Try setting it and see what your programs do about that.

I believe that the standards require that the system _use_ any TZ that is
set, not that TZ _be_ set.

Quote:>                                                              I thought of
> using gmtime and localtime and converting back to seconds and subtracting
> but mktime does a UTC conversion.

> I hope I do not have to do computation myself using gmtime and localtime. I
> was hoping the system would have an API call to give me detailed information
> as Win32 does.

Look in the (g)libc info pages in the node called "Functions and Variables
for Time Zones".

--


 
 
 

How to get timezone information

Post by Norman Blac » Wed, 03 May 2000 04:00:00


Thanks for taking the time to help Paul.
A POSIX book I have said the TZ was required but did not state the format so
I was hoping to reverse it by looking at the environment variable. I did see
some variables in the header file(s) about timezones, including exactly what
I wanted, but they did not seem to be POSIX. Since Linux is my first port of
two, and possibly others, I am trying to be very strict Posix/Xopen and then
succumb to Gnu(libc) or system specifics.

--
Norman Black
Stony Brook Software
To reply via email reverse the identifiers in the domain.



> > I am porting from Win32 and I am trying to found the timezone
information.
> > Specifically the number of hours/minutes offset from UTC.

> > I found information that Posix requires the TZ environment variable but
no
> > such environment variable exists on my system, Mandrake 7.0.

> It doesn't?  Try setting it and see what your programs do about that.

> I believe that the standards require that the system _use_ any TZ that is
> set, not that TZ _be_ set.

> >                                                              I thought
of
> > using gmtime and localtime and converting back to seconds and
subtracting
> > but mktime does a UTC conversion.

> > I hope I do not have to do computation myself using gmtime and
localtime. I
> > was hoping the system would have an API call to give me detailed
information
> > as Win32 does.

> Look in the (g)libc info pages in the node called "Functions and Variables
> for Time Zones".

> --


 
 
 

How to get timezone information

Post by Paul Kimo » Wed, 03 May 2000 04:00:00



>                      I did see
> some variables in the header file(s) about timezones, including exactly what
> I wanted, but they did not seem to be POSIX. Since Linux is my first port of
> two, and possibly others, I am trying to be very strict Posix/Xopen and then
> succumb to Gnu(libc) or system specifics.

In addition to the GNU libc info pages, this documentation (from the GNU
libc web pages) might interest you:

http://www.gnu.ai.mit.edu/software/libc/glibc-idx.html

--

 
 
 

How to get timezone information

Post by Norman Blac » Thu, 04 May 2000 04:00:00


Wow! thanks again.

--
Norman Black
Stony Brook Software
To reply via email reverse the identifiers in the domain.



> >                      I did see
> > some variables in the header file(s) about timezones, including exactly
what
> > I wanted, but they did not seem to be POSIX. Since Linux is my first
port of
> > two, and possibly others, I am trying to be very strict Posix/Xopen and
then
> > succumb to Gnu(libc) or system specifics.

> In addition to the GNU libc info pages, this documentation (from the GNU
> libc web pages) might interest you:

> http://www.gnu.ai.mit.edu/software/libc/glibc-idx.html

> --


 
 
 

1. getting the network interface information and default gateway information ??

hi,
  iam trying to get the network interface information and the default
information.After doing some googling i found out the relevant
structures and the ioctl calls for getting the interfaces information(
i suppose i have all that right).
struct ifconf(and using the ioctl SIOCGIFCONF).
there is another structure
struct ifreq
but i dont think i need that one.

Now how do i do to get the interface address(aliases also).i have
written a small program, but dont know where iam going wrong.the code
is

#include <stdio.h>
#include <stdlib.h>
#include <sys/ioctl.h>
#include <sys/types.h>
#include <net/if.h>
#include <netinet/in.h>

int
main(int argc, char* argv[])
{
    struct ifconf ifc;
    struct ifreq *ifr;
    struct sockaddr_in *sin;
    char buf[128];

    if ((s = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
        perror("socket");
        return 1;
    }

    ifc.ifc_buf = buf;
    ifc.ifc_len = sizeof(buf);
    if (ioctl(s, SIOCGIFCONF, &ifc) < 0) {
        perror("ioctl SIOCGIFCONF");
        return 1;
    }

    ifc.ifc_len /= sizeof(struct ifreq);
    for (i=0; i<ifc.ifc_len; i++) {
        ifr = (struct ifreq *) &ifc.ifc_req[i];
        sin = (struct sockaddr_in *) &ifr->ifr_addr;
        printf("%s \n",sin->sin_addr);
        }
    }
    return 0;

And how can i get the default gateway address within my program.

any help will be highly appreciated.

thanks
rohit

2. Monitoring HTTP Connections

3. How to set timezone information?

4. Pionneer 10X SCSI

5. Linux timezone information

6. Software for virtual Tape filesystems

7. Request for Timezone information

8. New 3rd Party H/W Guide via anon. FTP

9. Setting Timezone information.

10. Timezone-Information-Problem

11. Timezone information

12. How java gets TimeZone definitions on Solaris?