Time t

Time t

El tipo de dato time_t es un tipo de dato de la biblioteca ISO-C definido para el almacenamiento de valores de tiempo del sistema. Estos valores se devuelven desde la función time() de la biblioteca estándar. Este tipo es un typedef definido en la cabecera <time.h> . ISO-C define time_t como un tipo aritmético, pero no especifica ningun rango, resolución, o codificación en particular de la misma. Tampoco especifica los significados de las operaciones aritméticas aplicadas a los valores de tiempo.

Contenido

Implementación

Unix y los sistemas compatibles con POSIX, implementan time_t como un entero o real de coma flotante.[1] (generalmente entero de 32 o 64 bits), que representa el número de segundos desde el inicio del tiempo Unix: la medianoche del 1 de enero de 1970 UTC (sin contar los segundos intercalares). Algunos sistemas manejan correctamente los valores negativos, mientras que otros no lo hacen. Los sistemas que utilizan un tipo time_t entero de 32 bits son susceptibles a los problemas del año 2038.[2]

Además de la función time(), ISO-C también especifica otras funciones y tipos de conversión de sistema de valores de tiempo time_t en los tiempos del calendario y viceversa.

Ejemplo

El siguiente código en C devuelve la hora actual, le da formato de cadena, y lo escribe en la salida estándar.

#include <stdio.h>
#include <time.h>
 
/*
 * El resultado debe ser algo así como
 * Fri 2008-08-22 15:21:59 WAST
 */
 
int main(void)
{
    time_t     now;
    struct tm *ts;
    char       buf[80];
 
    /* Obtener la hora actual */
    now = time(0);
 
    /* Formatear e imprimir el tiempo, "ddd yyyy-mm-dd hh:mm:ss zzz" */
    ts = localtime(&now);
    strftime(buf, sizeof(buf), "%a %Y-%m-%d %H:%M:%S %Z", ts);
    printf("%s\n", buf);
 
    return 0;
}

La conversión a la hora civil

Usando GNU date, un valor dado time_t se puede convertir en su equivalente en la fecha del calendario:

$ date -ud@1234567890
Fri Feb 13 23:31:30 UTC 2009

Del mismo modo, usando BSD date:

$ date -ur 1234567890
Fri Feb 13 23:31:30 UTC 2009

Véase también

Referencias

  1. The Open Group Base Specifications Issue 7 sys/types.h. Retrieved on 2009-02-13.
  2. The Year 2038 problem, Roger M. Wilcox. Retrieved on 2011-03-11.



Wikimedia foundation. 2010.

Игры ⚽ Поможем написать курсовую

Mira otros diccionarios:

  • Time — Time, n.; pl. {Times}. [OE. time, AS. t[=i]ma, akin to t[=i]d time, and to Icel. t[=i]mi, Dan. time an hour, Sw. timme. [root]58. See {Tide}, n.] 1. Duration, considered independently of any system of measurement or any employment of terms which… …   The Collaborative International Dictionary of English

  • time — [tīm] n. [ME < OE tima, prob. < IE * dī men < base * dā(i) , to part, divide up > TIDE1] I duration; continuance 1. indefinite, unlimited duration in which things are considered as happening in the past, present, or future; every… …   English World dictionary

  • Time — • Article explores two questions, What are the notes, or elements, contained in the subjective representation of time? and To what external reality does this representation correspond? Catholic Encyclopedia. Kevin Knight. 2006. Time     Time …   Catholic encyclopedia

  • Time's Up! — is a grassroots environmental group that seeks to promote a more sustainable, less toxic New York City. For 20 years, it has been committed to improving the environment by empowering individuals to become active in their community. In New York… …   Wikipedia

  • TIME — (magazine) Pour les articles homonymes, voir Time.  Time Magazine {{{nomorigine}}} …   Wikipédia en Français

  • time — ► NOUN 1) the indefinite continued progress of existence and events in the past, present, and future, regarded as a whole. 2) a point of time as measured in hours and minutes past midnight or noon. 3) the favourable or appropriate moment to do… …   English terms dictionary

  • TIME — Erstausgabe 1923 Beschreibung Nachrichtenmagazi …   Deutsch Wikipedia

  • Time — Time …   Deutsch Wikipedia

  • Time.h — Saltar a navegación, búsqueda time.h es un archivo de cabecera de la biblioteca estándar del lenguaje de programación C que contiene funciones para manipular y formatear la fecha y hora del sistema. Contenido 1 Funciones 2 Constantes 3 Tipo …   Wikipedia Español

  • Time UK — is a computer retailer set up by the people behind the failed Time Computer Systems.The company is based within the main factory offices at Time Technology Park in Simonstone, near Burnley in Lancashire. The company specializes in providing… …   Wikipedia

  • TIME — Premier élément d’un gigantesque empire de presse dont l’histoire est intimement liée à l’action d’une des plus fortes personnalités du journalisme américain, Henry R. Luce (1903 1967), et à son ami Britton Hadden. La création du Time Weekly News …   Encyclopédie Universelle

Compartir el artículo y extractos

Link directo
Do a right-click on the link above
and select “Copy Link”