1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200
|
.\" 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 Thuermann,
.\" (urs@isnogud.escape.de), aeb, 950722.
.\" Modified 14 Jan 1997 by Austin Donnelly (and1000@debian.org):
.\" Added return values section, and bit on EFAULT
.\" Added clarification on timezone, aeb, 971210.
.\" Translated 15 Dec 1997 by Gerardo Aburruzaga G <gerardo.aburruzaga@uca.es>
.\" Translation revised Tue Aug 18 1998 by Juan Piernas <piernas@ditec.um.es>
.\"
.TH GETTIMEOFDAY 2 "10 Diciembre 1997" "Linux 2.0.32" "Manual del Programador de Linux"
.SH NOMBRE
gettimeofday, settimeofday \- pone u obtiene la hora
.SH SINOPSIS
.B #include <sys/time.h>
.br
.B #include <unistd.h>
.sp
.BI "int gettimeofday(struct timeval *" tv ", struct timezone *" tz );
.br
.BI "int settimeofday(const struct timeval *" tv
.BI ", const struct timezone *" tz );
.SH DESCRIPCIN
.B gettimeofday
y
.B settimeofday
pueden poner tanto la hora como una zona horaria.
.I tv
es una estructura
.BR timeval ,
tal como se especifica en /usr/include/sys/time.h:
.sp
.nf
struct timeval {
.in +8
long tv_sec; /* segundos */
long tv_usec; /* microsegundos */
.in -8
};
.fi
.PP
.sp
y
.I tz
es una estructura
.B timezone
:
.sp
.nf
struct timezone {
.in +8
int tz_minuteswest; /* minutos al O de Greenwich */
int tz_dsttime; /* tipo de correcin horaria invierno/verano */
.in -8
};
.fi
.PP
El uso de la estructura timezone es obsoleto; el campo
.I tz_dsttime
nunca ha sido utilizado en Linux - no lo ha sido y nunca ser soportado por
libc o glibc. Todas y cada una de las ocurrencias de este campo en el fuente
del ncleo (distintas de la declaracin) son un fallo. Por tanto, lo
siguiente es puramente de inters histrico.
El campo
.I tz_dsttime
contiene una constante simblica (los valores se dan ms abajo) que indica
en qu parte del ao la `correcin horaria invierno/verano' (Daylight Saving
Time, DST, tambin conocida como `horario de ahorro energtico') est en vigor.
(Nota: su valor es constante a lo largo del ao - no indica si DST est o no
en vigor, slo selecciona un algoritmo).
Los algoritmos de correccin horaria invierno/verano se definen como sigue:
.PP
.ta 14
\fB DST_NONE\fP /* no hay */
.br
\fB DST_USA\fP /* estilo EE.UU. */
.br
\fB DST_AUST\fP /* estilo australiano */
.br
\fB DST_WET\fP /* como en Europa Occidental */
.br
\fB DST_MET\fP /* como en Europa Central */
.br
\fB DST_EET\fP /* como en Europa del Este */
.br
\fB DST_CAN\fP /* Canad */
.br
\fB DST_GB\fP /* Gran Bretaa e Irlanda */
.br
\fB DST_RUM\fP /* Rumana */
.br
\fB DST_TUR\fP /* Turqua */
.br
\fB DST_AUSTALT\fP /* est. australiano con cambio en 1986 */
.PP
Naturalmente, result ser que el periodo en el que la correccin horaria
invierno/verano est en vigor no se poda dar mediante un simple algoritmo,
uno por pas: de hecho, este periodo se determina por decisiones polticas
impredecibles. Por tanto, este mtodo de representacin de las zonas
horarias se ha abandonado. Bajo Linux, en una llamada a
.B settimeofday
el campo
.I tz_dsttime
debe ser cero.
.PP
Bajo Linux hay algunas semnticas de `Warp clock' peculariares asociadas a
la llamada al sistema
.B settimeofday
si en la primera llamada de todas (despus del arranque) que tenga un
argumento
.I tz
no NULL, el argumento
.I tv
es NULL y el campo
.I tz_minuteswest
es no cero. En tal caso, se asume que el reloj CMOS est en el horario local
y que tiene que ser incrementado en esta cantidad para obtener el horario
del sistema UTC. No cabe duda que usar esta caracterstica es una mala idea.
.PP
Para operar sobre la estructura timeval se definen las siguientes macros:
.br
.nf
#define timerisset(tvp)\\
.ti +8
((tvp)->tv_sec || (tvp)->tv_usec)
#define timercmp(tvp, uvp, cmp)\\
.in +8
((tvp)->tv_sec cmp (uvp)->tv_sec ||\\
(tvp)->tv_sec == (uvp)->tv_sec &&\\
(tvp)->tv_usec cmp (uvp)->tv_usec)
.in -8
#define timerclear(tvp)\\
.ti +8
((tvp)->tv_sec = (tvp)->tv_usec = 0)
.fi
.PP
Si
.I tv
o
.I tz
es nulo, la estructura correspondiente no se ajusta ni se devuelve.
.PP
Solamente el super-usuario puede emplear
.BR settimeofday .
.SH "VALOR DEVUELTO"
.B gettimeofday
y
.B settimeofday
devuelven 0 en caso de xito -1 si ocurre un fallo (en cuyo caso
.I errno
toma un valor apropiado).
.SH ERRORES
.TP
.B EPERM
Alguien que no es el super-usuario ha llamado a
.B settimeofday
.
.TP
.B EINVAL
La zona horaria (o algo ms) es invlida.
.TP
.B EFAULT
Uno de
.I tv
o
.I tz
apuntaba afuera de su espacio de direcciones accesible.
.SH "CONFORME A"
SVr4, BSD 4.3
.SH "VASE TAMBIN"
.BR date "(1), " adjtimex "(2), " time "(2), " ctime "(3), " ftime "(3)"
|