.\" Hey Emacs! This file is -*- nroff -*- source. .\" .\" Copyright (c) 1992 Drew Eckhardt (drew@cs.colorado.edu), March 28, 1992 .\" .\" Permission is granted to make and distribute verbatim copies of this .\" manual provided the copyright notice and this permission notice are .\" preserved on all copies. .\" .\" Permission is granted to copy and distribute modified versions of this .\" manual under the conditions for verbatim copying, provided that the .\" entire resulting derived work is distributed under the terms of a .\" permission notice identical to this one .\" .\" Since the Linux kernel and libraries are constantly changing, this .\" manual page may be incorrect or out-of-date. The author(s) assume no .\" responsibility for errors or omissions, or for damages resulting from .\" the use of the information contained herein. The author(s) may not .\" have taken the same level of care in the production of this manual, .\" which is licensed free of charge, as they might when working .\" professionally. .\" .\" Formatted or processed versions of this manual, if unaccompanied by .\" the source, must acknowledge the copyright and authors of this work. .\" .\" Modified by Michael Haardt (u31b3hs@pool.informatik.rwth-aachen.de) .\" Modified Fri Jul 23 21:26:27 1993 by Rik Faith (faith@cs.unc.edu) .\" Modified 21 Aug 1994 by Michael Chastain (mec@shell.portal.com): .\" Fixed necessary '#include' lines. .\" Modified 15 Apr 1995 by Michael Chastain (mec@shell.portal.com): .\" Added reference to adjtimex. .\" Removed some nonsense lines pointed out by urs@isnogud.escape.de (Urs Thuermann), .\" aeb, 950722. .\" .TH GETTIMEOFDAY 2 "15 April 1995" "Linux 1.2.4" "Linux Programmer's Manual" .SH NAME gettimeofday, settimeofday \- get / set time .SH SYNOPSIS .B #include .br .B #include .sp .BI "int gettimeofday(struct timeval *" tv ", struct timezone *" tz ); .br .BI "int settimeofday(const struct timeval *" tv .BI ", const struct timezone *" tz ); .SH DESCRIPTION .B gettimeofday and .B settimeofday can set the time as well as a timezone. .I tv is a .B timeval struct, as specified in /usr/include/sys/time.h: .sp .nf struct timeval { .in 22 long tv_sec; /* seconds */ long tv_usec; /* microseconds */ }; .in 10 .fi .PP .sp and .I tz is a .B timezone : .sp .nf struct timezone { .in 23 int tz_minuteswest; /* minutes west of Greenwich */ int tz_dsttime; /* type of dst correction */ }; .in 10 .fi .PP With daylight savings times defined as follows : .PP .B DST_NONE /* not on dst */ .br .B DST_USA /* USA style dst */ .br .B DST_AUST /* Australian style dst */ .br .B DST_WET /* Western European dst */ .br .B DST_MET /* Middle European dst */ .br .B DST_EET /* Eastern European dst */ .br .B DST_CAN /* Canada */ .br .B DST_GB /* Great Britain and Eire */ .br .B DST_RUM /* Rumania */ .br .B DST_TUR /* Turkey */ .br .B DST_AUSTALT /* Australian style with shift in 1986 */ .PP And the following macros are defined to operate on this : .br .nf #define timerisset(tvp)\\ .ti 18 ((tvp)->tv_sec || (tvp)->tv_usec) #define timercmp(tvp, uvp, cmp)\\ .in 18 ((tvp)->tv_sec cmp (uvp)->tv_sec ||\\ (tvp)->tv_sec == (uvp)->tv_sec &&\\ (tvp)->tv_usec cmp (uvp)->tv_usec) .in 10 #define timerclear(tvp) .ti 18 ((tvp)->tv_sec = (tvp)->tv_usec = 0) .fi .PP If either .I tv or .I tz is null, the corresponding structure is not set or returned. .PP Only the super user may use .BR settimeofday . .SH ERRORS .TP .B EPERM .B settimeofday is called by someone other than the superuser. .TP .B EINVAL Timezone (or something else) is invalid. .SH "CONFORMING TO" BSD 4.3 .SH "SEE ALSO" .BR date "(1), " adjtimex "(2), " time "(2), " ctime "(3), " ftime "(3)"