std::chrono::time_point
Da cppreference.com
![]() | This page has been machine-translated from the English version of the wiki using Google Translate. The translation may contain errors and awkward wording. Hover over text to see the original version. You can help to fix errors and improve the translation. For instructions click here. |
Definido no cabeçalho <chrono> | ||
template< class Clock, | (desde C++11) | |
std::chrono::time_point
modelo de classe representa um ponto no tempo. Ele é implementado como se armazena um valor do tipo Duration
indica o intervalo de tempo desde o início da época do Clock
de. Original:
Class template
std::chrono::time_point
represents a point in time. It is implemented as if it stores a value of type Duration
indicating the time interval from the start of the Clock
's epoch. The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
Índice |
[editar]Tipos de membro
Tipo de membro Original: Member type The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. | Definition |
clock | Clock , o relógio em que este ponto de tempo é medidoOriginal: Clock , the clock on which this time point is measuredThe text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
duration | Duration , um tipo std::chrono::duration utilizado para medir o tempo decorrido desde epochOriginal: Duration , a std::chrono::duration type used to measure the time since epochThe text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
rep | Rep , um tipo de aritmética que representa o número de carrapatos de duraçãoOriginal: Rep , an arithmetic type representing the number of ticks of the durationThe text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
period | Period , um tipo std::ratio representa o período de duração do carrapatoOriginal: Period , a std::ratio type representing the tick period of the durationThe text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
[editar]Funções de membro
constrói um ponto novo tempo Original: constructs a new time point The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (função pública membro) | |
retorna o ponto de tempo como a duração desde o início do seu relógio Original: returns the time point as duration since the start of its clock The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (função pública membro) | |
modifica o ponto no tempo determinado pela duração Original: modifies the time point by the given duration The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (função pública membro) | |
[estática] | retorna o ponto de tempo correspondente à duração menor Original: returns the time point corresponding to the smallest duration The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (função public static membro) |
[estática] | returns the time point corresponding to the largest duration (função public static membro) |
[editar]Não-membros funções
especializa o traço std::common_type Original: specializes the std::common_type trait The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (especialização modelo. classe) | |
modifica o ponto no tempo determinado pela duração Original: modifies the time point by the given duration The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (modelo de função) | |
compara dois pontos de tempo Original: compares two time points The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (modelo de função) | |
converts a time point to another time point on the same clock, with a different duration (modelo de função) |
[editar]Exemplo
Esse exemplo imprime o tempo atual, menos de 24 horas:
Original:
This example prints the current time minus 24 hours:
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
#include <iostream>#include <iomanip>#include <ctime>#include <chrono> int main(){ std::chrono::time_point<std::chrono::system_clock> now; now = std::chrono::system_clock::now();std::time_t now_c = std::chrono::system_clock::to_time_t( now -std::chrono::hours(24));std::cout<<"One day ago, the time was "<<std::put_time(std::localtime(&now_c), "%F %T")<<'\n';}
Potencial saída:
One day ago, the time was 2011-10-25 12:00:08
[editar]Veja também
(C++11) | um intervalo de tempo 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. (modelo de classe) |