MyWebUniversity.com Home Page
 



OpenSolaris man pages main menu


Standard C Library Functions                     gettimeofday(3C)



NAME
     gettimeofday, settimeofday - get or set the date and time

SYNOPSIS
     #include 

     int gettimeofday(struct timeval *tp, void *tzp);


     int settimeofday(struct timeval *tp, void *tzp);


DESCRIPTION
     The gettimeofday()  function  gets  and  the  settimeofday()
     function  sets  the system's notion of the current time. The
     current  time  is   expressed   in   elapsed   seconds   and
     microseconds since 00:00 Universal Coordinated Time, January
     1, 1970. The resolution of  the  system  clock  is  hardware
     dependent;  the time may be updated continuously or in clock
     ticks.


     The  tp  argument  points  to  a  timeval  structure,  which
     includes the following members:

       long    tvsec;    /* seconds since Jan. 1, 1970 */
       long    tvusec;   /* and microseconds */



     If tp is a null pointer, the current time information is not
     returned or set.


     The TZ environment variable holds time zone information. See
     TIMEZONE(4).


     The tzp argument to  gettimeofday()  and  settimeofday()  is
     ignored.


     Only privileged processes can set the time of day.

RETURN VALUES
     Upon successful completion, 0 is returned.  Otherwise, -1 is
     returned and errno is set to indicate the error.

ERORS
     The settimeofday() function will fail if:





SunOS 5.11           Last change: 1 Aug 2003                    1






Standard C Library Functions                     gettimeofday(3C)



     EINVAL    The  structure  pointed  to  by  tp  specifies  an
               invalid time.


     EPERM     The {PRIVSYSTIME} privilege was not asserted  in
               the effective set of the calling process.



     The gettimeofday() function will fail for 32-bit  interfaces
     if:

     EOVERFLOW    The system time  has  progressed  beyond  2038,
                  thus  the  size  of  the  tvsec  member of the
                  timeval structure pointed to by tp is  insuffi-
                  cient to hold the current time in seconds.


USAGE
     If the tvusec member of  tp  is  >  500000,  settimeofday()
     rounds  the seconds upward. If the time needs to be set with
     better than one second accuracy, call settimeofday() for the
     seconds and then adjtime(2) for finer accuracy.

ATRIBUTES
     See attributes(5) for descriptions of the  following  attri-
     butes:



     
           ATRIBUTE TYPE               ATRIBUTE VALUE       
    
     Interface Stability          gettimeofday() is Standard. 
    
     MT-Level                     MT-Safe                     
    


SEE ALSO
     adjtime(2), ctime(3C),  gethrtime(3C),  TIMEZONE(4),  attri-
     butes(5), privileges(5), standards(5)













SunOS 5.11           Last change: 1 Aug 2003                    2



OpenSolaris man pages main menu

Contact us      |       About us      |       Term of use      |       Copyright © 2000-2010 MyWebUniversity.com ™