Provided by: manpages-es-dev_4.13-4_all bug

NOMBRE

       getdate, getdate_r - convert a date-plus-time string to broken-down time

SINOPSIS

       #include <time.h>

       struct tm *getdate(const char *string);

       extern int getdate_err;

       #include <time.h>

       int getdate_r(const char *string, struct tm *res);

   Requisitos de Macros de Prueba de Características para glibc (véase feature_test_macros(7)):

       getdate():
           _XOPEN_SOURCE >= 500
       getdate_r():
           _GNU_SOURCE

DESCRIPCIÓN

       The  function  getdate()   converts  a  string representation of a date and time, contained in the buffer
       pointed to by string, into a broken-down time.  The broken-down time is stored in a tm structure,  and  a
       pointer  to  this structure is returned as the function result.  This tm structure is allocated in static
       storage, and consequently it will be overwritten by further calls to getdate().

       En contraste con strptime(3), (que tiene un argumento format ), getdate() usa los formatos situados en el
       fichero del cual se especifica la ruta completa en la variable de entorno DATEMSK.  La primera línea  del
       fichero que concuerde con la cadena de entrada pasada se utiliza para la conversión.

       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.

       The conversion specifications that a pattern can contain are  those  given  for  strptime(3).   One  more
       conversion specification is specified in POSIX.1-2001:

       %Z     Timezone name.  This is not implemented in glibc.

       When  %Z 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 localtime(3)).

       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).

       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.

       Cuando no se dan ni hora, ni minutos, ni segundos, se toman la hora, minutos y segundos actuales.

       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).

       getdate_r()   is  a  GNU  extension  that provides a reentrant version of getdate().  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 res.

VALOR DEVUELTO

       When successful, getdate()  returns a pointer to a struct tm.  Otherwise, it returns NULL  and  sets  the
       global variable getdate_err to one of the error numbers shown below.  Changes to errno are unspecified.

       On success getdate_r()  returns 0; on error it returns one of the error numbers shown below.

ERRORES

       The  following  errors  are  returned  via  getdate_err  (for  getdate())  or as the function result (for
       getdate_r()):

       1   The DATEMSK environment variable is not defined, or its value is an empty string.

       2   The template file specified by DATEMSK cannot be opened for reading.

       3   Fallo al obtener información del estado del fichero.

       4   El fichero de plantillas no es un fichero regular.

       5   Se ha producido un error al leer el fichero de plantillas.

       6   Fallo en la reserva de memoria (no hay suficiente memoria disponible).

       7   No hay ninguna línea en el fichero que concuerde con la entrada.

       8   Especificación inválida de entrada.

ENTORNO

       DATEMSK
              Fichero que contiene patrones de formato.

       TZ, LC_TIME
              Variables usadas por strptime(3).

ATRIBUTOS

       Para obtener una explicación de los términos usados en esta sección, véase attributes(7).
       ┌─────────────┬────────────────────┬───────────────────────────────────┐
       │ InterfazAtributoValor                             │
       ├─────────────┼────────────────────┼───────────────────────────────────┤
       │ getdate()   │ Seguridad del hilo │ MT-Unsafe race:getdate env locale │
       ├─────────────┼────────────────────┼───────────────────────────────────┤
       │ getdate_r() │ Seguridad del hilo │ MT-Safe env locale                │
       └─────────────┴────────────────────┴───────────────────────────────────┘

CONFORME A

       POSIX.1-2001, POSIX.1-2008.

NOTAS

       La  especificación  POSIX.1  para  strptime(3)  contiene  especificaciones  de  conversión  que  usan  el
       modificador  %E o %O, mientras que tales especificaciones no se dan para getdate().  La implementación de
       glibc implementa getdate() usando strptime(3) por lo que  automáticamente  las  mismas  conversiones  son
       soportadas por ambas.

EJEMPLOS

       The program below calls getdate()  for each of its command-line arguments, and for each call displays the
       values  in  the  fields  of  the  returned  tm  structure.   The following shell session demonstrates the
       operation of the program:

           $ TFILE=$PWD/tfile
           $ echo '%A' > $TFILE       # Full name of the day of the week
           $ echo '%T' >> $TFILE      # ISO date (YYYY-MM-DD)
           $ echo '%F' >> $TFILE      # Time (HH:MM:SS)
           $ date
           $ export DATEMSK=$TFILE
           $ ./a.out Tuesday '2009-12-28' '12:22:33'
           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

   Program source

       #define _GNU_SOURCE
       #include <time.h>
       #include <stdio.h>
       #include <stdlib.h>

       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\n",
                          j, getdate_err);
                   continue;
               }

               printf("Call %d (\"%s\") succeeded:\n", j, argv[j]);
               printf("    tm_sec   = %d\n", tmp->tm_sec);
               printf("    tm_min   = %d\n", tmp->tm_min);
               printf("    tm_hour  = %d\n", tmp->tm_hour);
               printf("    tm_mday  = %d\n", tmp->tm_mday);
               printf("    tm_mon   = %d\n", tmp->tm_mon);
               printf("    tm_year  = %d\n", tmp->tm_year);
               printf("    tm_wday  = %d\n", tmp->tm_wday);
               printf("    tm_yday  = %d\n", tmp->tm_yday);
               printf("    tm_isdst = %d\n", tmp->tm_isdst);
           }

           exit(EXIT_SUCCESS);
       }

VÉASE TAMBIÉN

       time(2), localtime(3), setlocale(3), strftime(3), strptime(3)

COLOFÓN

       Esta página es parte de la versión 5.10 del proyecto Linux man-pages. 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/.

TRADUCCIÓN

       La traducción al español de esta página del manual fue creada por Miguel Pérez Ibars <mpi79470@alu.um.es>

       Esta  traducción  es  documentación  libre;  lea  la GNU General Public License Version 3 o posterior con
       respecto a las condiciones de copyright.  No existe NINGUNA RESPONSABILIDAD.

       Si encuentra algún error en la traducción de esta página  del  manual,  envíe  un  correo  electrónico  a
       debian-l10n-spanish@lists.debian.org.

                                                1 Noviembre 2020                                      GETDATE(3)