xref: /csrg-svn/lib/libc/sys/gettimeofday.2 (revision 61181)
1*61181Sbostic.\" Copyright (c) 1980, 1991, 1993
2*61181Sbostic.\"	The Regents of the University of California.  All rights reserved.
320138Smckusick.\"
443568Strent.\" %sccs.include.redist.man%
520138Smckusick.\"
6*61181Sbostic.\"     @(#)gettimeofday.2	8.1 (Berkeley) 06/04/93
738053Sbostic.\"
847208Scael.Dd
947208Scael.Dt GETTIMEOFDAY 2
1047208Scael.Os BSD 4
1147208Scael.Sh NAME
1247208Scael.Nm gettimeofday ,
1347208Scael.Nm settimeofday
1447208Scael.Nd get/set date and time
1547208Scael.Sh SYNOPSIS
1647208Scael.Fd #include <sys/time.h>
1747208Scael.Ft int
1847208Scael.Fn gettimeofday "struct timeval *tp" "struct timezone *tzp"
1947208Scael.Ft int
2047208Scael.Fn settimeofday "struct timeval *tp" "struct timezone *tzp"
2147208Scael.Sh DESCRIPTION
2247208Scael.Bf -symbolic
2347208ScaelNote: timezone is no longer used; this information is kept outside
2447208Scaelthe kernel.
2547208Scael.Ef
2630889SbosticThe system's notion of the current Greenwich time and the current time
2747208Scaelzone is obtained with the
2847208Scael.Fn gettimeofday
2947208Scaelcall, and set with the
3047208Scael.Fn settimeofday
3147208Scaelcall.  The time is expressed in seconds and microseconds
3230889Sbosticsince midnight (0 hour), January 1, 1970.  The resolution of the system
3330889Sbosticclock is hardware dependent, and the time may be updated continuously or
3447208Scaelin ``ticks.''  If
3547208Scael.Fa tp
3647208Scaelor
3747208Scael.Fa tzp
3847208Scaelis NULL, the associated time
3930889Sbosticinformation will not be returned or set.
4047208Scael.Pp
4120139SmckusickThe structures pointed to by
4247208Scael.Fa tp
4320139Smckusickand
4447208Scael.Fa tzp
4520139Smckusickare defined in
4647208Scael.Ao Pa sys/time.h Ac
4720139Smckusickas:
4847208Scael.Pp
4947208Scael.Bd -literal
5020139Smckusickstruct timeval {
5127648Slepreau	long	tv_sec;		/* seconds since Jan. 1, 1970 */
5247208Scael	long	tv_usec;	/* and microseconds */
5320139Smckusick};
5447208Scael
5520139Smckusickstruct timezone {
5647208Scael	int	tz_minuteswest; /* of Greenwich */
5720139Smckusick	int	tz_dsttime;	/* type of dst correction to apply */
5820139Smckusick};
5947208Scael.Ed
6047208Scael.Pp
6120139SmckusickThe
6247208Scael.Fa timezone
6320139Smckusickstructure indicates the local time zone
6420139Smckusick(measured in minutes of time westward from Greenwich),
6520139Smckusickand a flag that, if nonzero, indicates that
6620139SmckusickDaylight Saving time applies locally during
6720139Smckusickthe appropriate part of the year.
6847208Scael.Pp
6927648SlepreauOnly the super-user may set the time of day or time zone.
7047208Scael.Sh RETURN
7120139SmckusickA 0 return value indicates that the call succeeded.
7247208ScaelA -1 return value indicates an error occurred, and in this
7347208Scaelcase an error code is stored into the global variable
7447208Scael.Va errno .
7547208Scael.Sh ERRORS
7647208ScaelThe following error codes may be set in
7747208Scael.Va errno :
7847208Scael.Bl -tag -width [EFAULT]
7947208Scael.It Bq Er EFAULT
8020139SmckusickAn argument address referenced invalid memory.
8147208Scael.It Bq Er EPERM
8220139SmckusickA user other than the super-user attempted to set the time.
8347208Scael.El
8447208Scael.Sh SEE ALSO
8547208Scael.Xr date 1 ,
8647208Scael.Xr adjtime 2 ,
8747208Scael.Xr ctime 3 ,
8847208Scael.Xr timed 8
8947208Scael.Sh HISTORY
9047208ScaelThe
9147208Scael.Nm
9247208Scaelfunction call appeared in
9347208Scael.Bx 4.2 .
94