Penguin
Blame: gettimeofday(2)
EditPageHistoryDiffInfoLikePages
Annotated edit history of gettimeofday(2) version 2, including all changes. View license author blame.
Rev Author # Line
1 perry 1 !!NAME
2 PerryLorier 2 gettimeofday - get time
1 perry 3 !!SYNOPSIS
2 PerryLorier 4 __#include <sys/time.h>__
5 __#include <time.h>__
6 __int gettimeofday(struct timeval *__''tv''__, struct timezone *__''tz''__);__
1 perry 7 !!DESCRIPTION
2 PerryLorier 8 __gettimeofday__ can get the time as well as a timezone. ''tv'' is a __timeval__ struct, as specified in /usr/include/sys/time.h:
1 perry 9
2 PerryLorier 10 struct timeval {
11 long tv_sec; /* seconds */
12 long tv_usec; /* microseconds */
13 };
1 perry 14
2 PerryLorier 15 The ''tv_sec'' member of the struct is the number of seconds since the Epoch (see time(2)), and ''tv_usec'' is the amount of microseconds past the current ''tv_sec'' value.
1 perry 16
17 The ''tz'' argument is a __timezone__ :
18
2 PerryLorier 19 struct timezone {
20 int tz_minuteswest; /* minutes W of Greenwich */
21 int tz_dsttime; /* type of dst correction */
22 };
1 perry 23 The use of the timezone struct is obsolete; the ''tz_dsttime'' field has never been used under Linux - it has not been and will not be supported by libc or glibc. Each and every occurrence of this field in the kernel source (other than the declaration) is a bug. Thus, the following is purely of historic interest.
24
2 PerryLorier 25 The field ''tz_dsttime'' contains a symbolic constant (values are given below) that indicates in which part of the year Daylight Saving Time is in force. (Note: its value is constant throughout the year - it does not indicate that DST is in force, it just selects an algorithm.) The daylight saving time algorithms defined are as follows :
1 perry 26
2 PerryLorier 27 __DST_NONE__ /* not on dst */
28 __DST_USA__ /* USA style dst */
29 __DST_AUST__ /* Australian style dst */
30 __DST_WET__ /* Western European dst */
31 __DST_MET__ /* Middle European dst */
32 __DST_EET__ /* Eastern European dst */
33 __DST_CAN__ /* Canada */
34 __DST_GB__ /* Great Britain and Eire */
35 __DST_RUM__ /* Rumania */
36 __DST_TUR__ /* Turkey */
37 __DST_AUSTALT__ /* Australian style with shift in 1986 */
1 perry 38
2 PerryLorier 39 Of course it turned out that the period in which Daylight Saving Time is in force cannot be given by a simple algorithm, one per country; indeed, this period is determined by unpredictable political decisions. So this method of representing time zones has been abandoned.
1 perry 40
2 PerryLorier 41 The following macros are defined to operate on a struct timeval :
1 perry 42
2 PerryLorier 43 #define timerisset(tvp)\
44 ((tvp)->tv_sec || (tvp)->tv_usec)
45 #define timercmp(tvp, uvp, cmp)\
46 ((tvp)->tv_sec cmp (uvp)->tv_sec ||\
47 (tvp)->tv_sec == (uvp)->tv_sec &&\
48 (tvp)->tv_usec cmp (uvp)->tv_usec)
49 #define timerclear(tvp)\
50 ((tvp)->tv_sec = (tvp)->tv_usec = 0)
1 perry 51
52
53 If either ''tv'' or ''tz'' is null, the corresponding structure is not set or returned.
54
55 !!RETURN VALUE
2 PerryLorier 56 gettimeofday(2) return 0 for success, or -1 for failure (in which case ''errno'' is set appropriately).
1 perry 57
58 !!ERRORS
2 PerryLorier 59 ;[EINVAL]: Timezone (or something else) is invalid.
60 ;[EFAULT]: One of ''tv'' or ''tz'' pointed outside your accessible address space.
1 perry 61
62 !!NOTE
2 PerryLorier 63 The defines for __timercmp__, __timerisset__, __timerclear__, __timeradd__, __timersub__ are (since glibc2.2.2) only available if ___BSD_SOURCE__ is defined (either explicitly, or implicitly, by not defining _POSIX_SOURCE or compiling with the -ansi flag).
1 perry 64
65 !!CONFORMING TO
2 PerryLorier 66 SVr4, BSD 4.3
1 perry 67
68 !!SEE ALSO
2 PerryLorier 69 date(1), adjtimex(2), time(2), ctime(3), ftime(3)
This page is a man page (or other imported legacy content). We are unable to automatically determine the license status of this page.

PHP Warning

lib/blame.php:177: Warning: Invalid argument supplied for foreach() (...repeated 8 times)