std::chrono..._since_epoch(3)
π NAME π
std::chrono::time_point::time_since_epoch - std::chrono::time_point::time_since_epoch β yes bestie, the NAME section is literally that twice, and this is the std::chrono..._since_epoch(3) page from the C++ Standard Libary (spelled βLibaryβ in the header, iconic π). Itβs giving tiny chrono member function with main character energy, fr fr.
β¨ Synopsis β¨
Okay so the signature is short and slay:
duration time_since_epoch() const; (since C++11)
(constexpr since C++14)
Returns a duration representing the amount of time between *this and the clock's epoch. Thatβs the whole vibe β no cap. π«Ά
π Parameters π
(none) β literally none, bestie. Not a single parameter. The parameter list ate and left no crumbs. π
π Return value π
The amount of time between this time_point and the clock's epoch. Thatβs it. Thatβs the tea. β¨
π Example π
Before the code, the page says: // Run this code
#include <chrono>
#include <ctime>
#include <iostream>
int main()
{
const auto p0 =
std::chrono::time_point<std::chrono::system_clock>{};
const auto p1 = std::chrono::system_clock::now();
const auto p2 = p1 - std::chrono::hours(24);
std::time_t epoch_time = std::chrono::system_clock::to_time_t(p0);
std::cout << "epoch: " << std::ctime(&epoch_time);
std::time_t today_time = std::chrono::system_clock::to_time_t(p1);
std::cout << "today: " << std::ctime(&today_time);
std::cout << "hours since epoch: "
<< std::chrono::duration_cast<std::chrono::hours>(
p1.time_since_epoch()).count()
<< '\n';
std::cout << "yesterday, hours since epoch: "
<< std::chrono::duration_cast<std::chrono::hours>(
p2.time_since_epoch()).count()
<< '\n';
}
π Possible output: π
epoch: Thu Jan 1 00:00:00 1970
today: Fri Jun 30 10:44:11 2017
hours since epoch: 416338
yesterday, hours since epoch: 416314
source: http://cppreference.com Β· date: 2024.06.10 Β· page: std::chrono..._since_epoch(3) β mwah, bestie, go check those clocks πβ¨
π¦ where this page comes from
- nixpkgs unstable: stdman 2024.07.05
- opensuse-leap 16.0: stdman 2024.07.05-bp160.1.9 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms