Espacios de nombres
Variantes
Acciones

Date and time utilities

De cppreference.com
< cpp


 
 
Utilidades de la biblioteca
Escriba apoyo (basic types, RTTI, type traits)
Gestión de memoria dinámica
Gestión de errores
Programa de servicios públicos
Funciones variadic
Fecha y hora
Objetos Function
initializer_list(C++11)
bitset
hash(C++11)
Operadores relacionales
Original:
Relational operators
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
rel_ops::operator!=
rel_ops::operator>
rel_ops::operator<=
rel_ops::operator>=
Pares y tuplas
Original:
Pairs and tuples
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
pair
tuple(C++11)
piecewise_construct_t(C++11)
piecewise_construct(C++11)
Cambiar, hacia adelante y mover
Original:
Swap, forward and move
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
swap
forward(C++11)
move(C++11)
move_if_noexcept(C++11)
declval(C++11)
 
Fecha y hora de los servicios públicos
 
C + + incluye soporte para dos tipos de manipulación del tiempo:
Original:
C++ includes support for two types of time manipulation:
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
  • La biblioteca chrono, una colección flexible de tipos que rastrean tiempo con diferentes grados de precisión (por ejemplo std::chrono::time_point) .
    Original:
    The chrono library, a flexible collection of types that track time with varying degrees of precision (e.g. std::chrono::time_point).
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • C-estilo biblioteca de fecha y hora (por ejemplo std::time)
    Original:
    C-style date and time library (e.g. std::time)
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.

Contenido

[editar] NJ biblioteca

La biblioteca chrono define tres tipos principales (duraciones, relojes, y los puntos de tiempo), así como funciones de utilidad y typedefs comunes .
Original:
The chrono library defines three main types (durations, clocks, and time points) as well as utility functions and common typedefs.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[editar] Duración

Una duración consta de un lapso de tiempo, que se define como un número de garrapatas de alguna otra unidad de tiempo. Por ejemplo, "42 segundos" puede ser representado por una duración que consiste de 42 garrapatas de una unidad de tiempo 1-segundos .
Original:
A duration consists of a span of time, defined as some number of ticks of some time unit. For example, "42 seconds" could be represented by a duration consisting of 42 ticks of a 1-second time unit.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Defined in header <chrono>
Defined in namespace std::chrono
(C++11)
un intervalo de tiempo
Original:
a time interval
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(clase de plantilla) [edit]

[editar] Relojes

Un reloj consta de un punto de partida (o época) y una tasa de garrapata. Por ejemplo, un reloj puede tener una época del 1 de enero de 1970 y marque cada segundo. C + + define tres tipos de reloj:
Original:
A clock consists of a starting point (or epoch) and a tick rate. For example, a clock may have an epoch of January 1, 1970 and tick every second. C++ defines three clock types:
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Defined in header <chrono>
Defined in namespace std::chrono
pared tiempo reloj desde el reloj en tiempo real de todo el sistema
Original:
wall clock time from the system-wide realtime clock
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(clase) [edit]
reloj monotónico que nunca va a ser ajustado
Original:
monotonic clock that will never be adjusted
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(clase) [edit]
el reloj con el período más corto garrapata disponible
Original:
the clock with the shortest tick period available
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(clase) [edit]

[editar] Hora punto

Un punto de tiempo es un periodo de tiempo que ha pasado desde la época de reloj específico .
Original:
A time point is a duration of time that has passed since the epoch of specific clock.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Defined in header <chrono>
Defined in namespace std::chrono
a point in time
(clase de plantilla) [edit]

[editar] C-estilo de la fecha y la biblioteca de tiempo

También se proporcionan las funciones de lenguaje C de fecha y hora, como std::time_t, std::difftime y CLOCKS_PER_SEC .
Original:
Also provided are the C-style date and time functions, such as std::time_t, std::difftime, and CLOCKS_PER_SEC.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[editar] Ejemplo

En este ejemplo se muestra información sobre el tiempo de ejecución de una llamada a la función:
Original:
This example displays information about the execution time of a function call:
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

#include <iostream>
#include <chrono>
#include <ctime>
 
int fibonacci(int n)
{
    if (n < 3) return 1;
    return fibonacci(n-1) + fibonacci(n-2);
}
 
int main()
{
    std::chrono::time_point<std::chrono::system_clock> start, end;
    start = std::chrono::system_clock::now();
    int result = fibonacci(42);
    end = std::chrono::system_clock::now();
 
    int elapsed_seconds = std::chrono::duration_cast<std::chrono::seconds>
                             (end-start).count();
    std::time_t end_time = std::chrono::system_clock::to_time_t(end);
 
    std::cout << "finished computation at " << std::ctime(&end_time)
              << "elapsed time: " << elapsed_seconds << "s\n";
}

Possible output:

finished computation at Sat Jun 16 20:42:57 2012
elapsed time: 3s