.\" -*- coding: UTF-8 -*- .\" Copyright 2001 walter harms (walter.harms@informatik.uni-oldenburg.de) .\" and Copyright 2008, Linux Foundation, written by Michael Kerrisk .\" .\" .\" %%%LICENSE_START(VERBATIM) .\" 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. .\" %%%LICENSE_END .\" .\" Modified, 2001-12-26, aeb .\" 2008-09-07, mtk, Various rewrites; added an example program. .\" .\"******************************************************************* .\" .\" This file was generated with po4a. Translate the source file. .\" .\"******************************************************************* .TH GETDATE 3 "1 Noviembre 2020" "" "Manual del Programador de Linux" .SH NOMBRE getdate, getdate_r \- convert a date\-plus\-time string to broken\-down time .SH SINOPSIS \fB#include \fP .PP \fBstruct tm *getdate(const char *\fP\fIstring\fP\fB);\fP .PP \fBextern int getdate_err;\fP .PP \fB#include \fP .PP \fBint getdate_r(const char *\fP\fIstring\fP\fB, struct tm *\fP\fIres\fP\fB);\fP .PP .RS -4 Requisitos de Macros de Prueba de Características para glibc (véase \fBfeature_test_macros\fP(7)): .RE .PP \fBgetdate\fP(): .ad l .RS 4 .\" || _XOPEN_SOURCE\ &&\ _XOPEN_SOURCE_EXTENDED _XOPEN_SOURCE\ >=\ 500 .RE .br \fBgetdate_r\fP(): .ad l .RS 4 _GNU_SOURCE .RE .ad .SH DESCRIPCIÓN The function \fBgetdate\fP() converts a string representation of a date and time, contained in the buffer pointed to by \fIstring\fP, into a broken\-down time. The broken\-down time is stored in a \fItm\fP structure, and a pointer to this structure is returned as the function result. This \fItm\fP structure is allocated in static storage, and consequently it will be overwritten by further calls to \fBgetdate\fP(). .PP En contraste con \fBstrptime\fP(3), (que tiene un argumento \fIformat\fP ), \fBgetdate\fP() usa los formatos situados en el fichero del cual se especifica la ruta completa en la variable de entorno \fBDATEMSK\fP. La primera línea del fichero que concuerde con la cadena de entrada pasada se utiliza para la conversión. .PP La correspondencia se hace sin tener en cuenta las mayúsculas. Los espacios innecesarios, ya sea en el patrón o en la cadena que debe ser convertida, se ignoran. .PP The conversion specifications that a pattern can contain are those given for \fBstrptime\fP(3). One more conversion specification is specified in POSIX.1\-2001: .TP \fB%Z\fP .\" FIXME Is it (still) true that %Z is not supported in glibc? .\" Looking at the glibc 2.21 source code, where the implementation uses .\" strptime(), suggests that it might be supported. Timezone name. This is not implemented in glibc. .PP When \fB%Z\fP is given, the structure containing the broken\-down time is initialized with values corresponding to the current time in the given timezone. Otherwise, the structure is initialized to the broken\-down time corresponding to the current local time (as by a call to \fBlocaltime\fP(3)). .PP Cuando sólo se especifica el día de la semana, el día que se toma es el primero tras el día actual (que podría ser el propio día actual). .PP Cuando sólo se especifica el mes (y no el año), el mes que se toma es el primero tras el mes actual (que podría ser el propio mes actual). Si no se especifica el día, se toma el primer día del mes. .PP Cuando no se dan ni hora, ni minutos, ni segundos, se toman la hora, minutos y segundos actuales. .PP Si no se especifica la fecha, pero sabemos la hora, entonces la hora se toma para que sea la primera tras la hora actual (que podría ser la propia hora actual). .PP \fBgetdate_r\fP() is a GNU extension that provides a reentrant version of \fBgetdate\fP(). Rather than using a global variable to report errors and a static buffer to return the broken down time, it returns errors via the function result value, and returns the resulting broken\-down time in the caller\-allocated buffer pointed to by the argument \fIres\fP. .SH "VALOR DEVUELTO" When successful, \fBgetdate\fP() returns a pointer to a \fIstruct tm\fP. Otherwise, it returns NULL and sets the global variable \fIgetdate_err\fP to one of the error numbers shown below. Changes to \fIerrno\fP are unspecified. .PP On success \fBgetdate_r\fP() returns 0; on error it returns one of the error numbers shown below. .SH ERRORES The following errors are returned via \fIgetdate_err\fP (for \fBgetdate\fP()) or as the function result (for \fBgetdate_r\fP()): .TP 4n \fB1\fP The \fBDATEMSK\fP environment variable is not defined, or its value is an empty string. .TP \fB2\fP The template file specified by \fBDATEMSK\fP cannot be opened for reading. .TP \fB3\fP .\" stat() Fallo al obtener información del estado del fichero. .TP \fB4\fP El fichero de plantillas no es un fichero regular. .TP \fB5\fP Se ha producido un error al leer el fichero de plantillas. .TP \fB6\fP .\" Error 6 doesn't seem to occur in glibc Fallo en la reserva de memoria (no hay suficiente memoria disponible). .TP \fB7\fP No hay ninguna línea en el fichero que concuerde con la entrada. .TP \fB8\fP Especificación inválida de entrada. .SH ENTORNO .TP \fBDATEMSK\fP Fichero que contiene patrones de formato. .TP \fBTZ\fP, \fBLC_TIME\fP Variables usadas por \fBstrptime\fP(3). .SH ATRIBUTOS Para obtener una explicación de los términos usados en esta sección, véase \fBattributes\fP(7). .TS allbox; lb lb lb l l l. Interfaz Atributo Valor T{ \fBgetdate\fP() T} Seguridad del hilo MT\-Unsafe race:getdate env locale T{ \fBgetdate_r\fP() T} Seguridad del hilo MT\-Safe env locale .TE .SH "CONFORME A" POSIX.1\-2001, POSIX.1\-2008. .SH NOTAS La especificación POSIX.1 para \fBstrptime\fP(3) contiene especificaciones de conversión que usan el modificador \fB%E\fP o \fB%O\fP, mientras que tales especificaciones no se dan para \fBgetdate\fP(). La implementación de glibc implementa \fBgetdate\fP() usando \fBstrptime\fP(3) por lo que automáticamente las mismas conversiones son soportadas por ambas. .SH EJEMPLOS The program below calls \fBgetdate\fP() for each of its command\-line arguments, and for each call displays the values in the fields of the returned \fItm\fP structure. The following shell session demonstrates the operation of the program: .PP .in +4n .EX $\fB TFILE=$PWD/tfile\fP $\fB echo \(aq%A\(aq > $TFILE \fP # Full name of the day of the week $\fB echo \(aq%T\(aq >> $TFILE\fP # ISO date (YYYY\-MM\-DD) $\fB echo \(aq%F\(aq >> $TFILE\fP # Time (HH:MM:SS) $\fB date\fP $\fB export DATEMSK=$TFILE\fP $\fB ./a.out Tuesday \(aq2009\-12\-28\(aq \(aq12:22:33\(aq\fP Sun Sep 7 06:03:36 CEST 2008 Call 1 ("Tuesday") succeeded: tm_sec = 36 tm_min = 3 tm_hour = 6 tm_mday = 9 tm_mon = 8 tm_year = 108 tm_wday = 2 tm_yday = 252 tm_isdst = 1 Call 2 ("2009\-12\-28") succeeded: tm_sec = 36 tm_min = 3 tm_hour = 6 tm_mday = 28 tm_mon = 11 tm_year = 109 tm_wday = 1 tm_yday = 361 tm_isdst = 0 Call 3 ("12:22:33") succeeded: tm_sec = 33 tm_min = 22 tm_hour = 12 tm_mday = 7 tm_mon = 8 tm_year = 108 tm_wday = 0 tm_yday = 250 tm_isdst = 1 .EE .in .SS "Código fuente" \& .EX #define _GNU_SOURCE #include #include #include int main(int argc, char *argv[]) { struct tm *tmp; for (int j = 1; j < argc; j++) { tmp = getdate(argv[j]); if (tmp == NULL) { printf("Call %d failed; getdate_err = %d\en", j, getdate_err); continue; } printf("Call %d (\e"%s\e") succeeded:\en", j, argv[j]); printf(" tm_sec = %d\en", tmp\->tm_sec); printf(" tm_min = %d\en", tmp\->tm_min); printf(" tm_hour = %d\en", tmp\->tm_hour); printf(" tm_mday = %d\en", tmp\->tm_mday); printf(" tm_mon = %d\en", tmp\->tm_mon); printf(" tm_year = %d\en", tmp\->tm_year); printf(" tm_wday = %d\en", tmp\->tm_wday); printf(" tm_yday = %d\en", tmp\->tm_yday); printf(" tm_isdst = %d\en", tmp\->tm_isdst); } exit(EXIT_SUCCESS); } .EE .SH "VÉASE TAMBIÉN" \fBtime\fP(2), \fBlocaltime\fP(3), \fBsetlocale\fP(3), \fBstrftime\fP(3), \fBstrptime\fP(3) .SH COLOFÓN Esta página es parte de la versión 5.10 del proyecto Linux \fIman\-pages\fP. Puede encontrar una descripción del proyecto, información sobre cómo informar errores y la última versión de esta página en \%https://www.kernel.org/doc/man\-pages/. .PP .SH TRADUCCIÓN La traducción al español de esta página del manual fue creada por Miguel Pérez Ibars . .PP Esta traducción es documentación libre; lea la .UR https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3 .UE o posterior con respecto a las condiciones de copyright. No existe NINGUNA RESPONSABILIDAD. .PP Si encuentra algún error en la traducción de esta página del manual, envíe un correo electrónico a .MT debian-l10n-spanish@lists.debian.org .ME .