Espaços nominais
Variantes
Acções

std::chrono::time_point::time_since_epoch

Da cppreference.com
< cpp‎ | chrono‎ | time point

 
 
Biblioteca de utilitários
Digite apoio (basic types, RTTI, type traits)
Gerenciamento de memória dinâmica
De tratamento de erros
Utilidades do programa
Variadic funções
Data e hora
Objetos de função
initializer_list(C++11)
bitset
hash(C++11)
Os operadores relacionais
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 e 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)
Troque, avançar e avançar
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)
 
 
std::chrono::time_point
Funções de membro
Original:
Member functions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
time_point::time_point
time_point::time_since_epoch
time_point::operator+
time_point::operator-
time_point::min
time_point::max
Não-membros funções
Original:
Non-member functions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
common_type
operator+
operator-
operator==
operator!=
operator<
operator<=
operator>
operator>=
time_point_cast
 
std::chrono::duration time_since_epoch() const;
Retorna uma std::chrono::duration representa a quantidade de tempo entre *this e época do clock de.
Original:
Returns a std::chrono::duration representing the amount of time between *this and 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.

[editar] Parâmetros

(Nenhum)
Original:
(none)
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[editar] Valor de retorno

a quantidade de tempo entre este e time_point o epoch da clock
Original:
the amount of time between this time_point and 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.

[editar] Exemplo

#include <iostream>
#include <chrono>
#include <ctime>
 
int main()
{
    std::chrono::time_point<std::chrono::system_clock> p1, p2, p3;
 
    p2 = std::chrono::system_clock::now();
    p3 = p2 - std::chrono::hours(24);
 
    std::time_t epoch_time = std::chrono::system_clock::to_time_t(p1);
    std::cout << "epoch: " << std::ctime(&epoch_time);
    std::time_t today_time = std::chrono::system_clock::to_time_t(p2);
    std::cout << "today: " << std::ctime(&today_time);
 
    std::cout << "hours since epoch: "
              << std::chrono::duration_cast<std::chrono::hours>(
                   p2.time_since_epoch()).count() 
              << '\n';
    std::cout << "yesterday, hours since epoch: "
              << std::chrono::duration_cast<std::chrono::hours>(
                   p3.time_since_epoch()).count() 
              << '\n';
}

Possible output:

epoch: Wed Dec 31 19:00:00 1969
today: Tue Jun 19 12:05:37 2012
hours since epoch: 372256
yesterday, hours since epoch: 372232