Bitcoin ABC  0.26.3
P2P Digital Currency
Typedefs | Functions
time.h File Reference
#include <compat.h>
#include <chrono>
#include <cstdint>
#include <string>
Include dependency graph for time.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Typedefs

using SecondsDouble = std::chrono::duration< double, std::chrono::seconds::period >
 

Functions

void UninterruptibleSleep (const std::chrono::microseconds &n)
 
constexpr int64_t count_seconds (std::chrono::seconds t)
 Helper to count the seconds of a duration. More...
 
constexpr int64_t count_milliseconds (std::chrono::milliseconds t)
 
constexpr int64_t count_microseconds (std::chrono::microseconds t)
 
double CountSecondsDouble (SecondsDouble t)
 Helper to count the seconds in any std::chrono::duration type. More...
 
int64_t GetTime ()
 DEPRECATED Use either GetTimeSeconds (not mockable) or GetTime<T> (mockable) More...
 
int64_t GetTimeMillis ()
 Returns the system time (not mockable) More...
 
int64_t GetTimeMicros ()
 Returns the system time (not mockable) More...
 
int64_t GetTimeSeconds ()
 Returns the system time (not mockable) More...
 
void SetMockTime (int64_t nMockTimeIn)
 DEPRECATED Use SetMockTime with chrono type. More...
 
void SetMockTime (std::chrono::seconds mock_time_in)
 For testing. More...
 
std::chrono::seconds GetMockTime ()
 For testing. More...
 
std::string FormatISO8601DateTime (int64_t nTime)
 ISO 8601 formatting is preferred. More...
 
std::string FormatISO8601Date (int64_t nTime)
 
int64_t ParseISO8601DateTime (const std::string &str)
 
struct timeval MillisToTimeval (int64_t nTimeout)
 Convert milliseconds to a struct timeval for e.g. More...
 
struct timeval MillisToTimeval (std::chrono::milliseconds ms)
 Convert milliseconds to a struct timeval for e.g. More...
 
bool ChronoSanityCheck ()
 Sanity check epoch match normal Unix epoch. More...
 

Typedef Documentation

◆ SecondsDouble

using SecondsDouble = std::chrono::duration<double, std::chrono::seconds::period>

Definition at line 39 of file time.h.

Function Documentation

◆ ChronoSanityCheck()

bool ChronoSanityCheck ( )

Sanity check epoch match normal Unix epoch.

Definition at line 30 of file time.cpp.

Here is the caller graph for this function:

◆ count_microseconds()

constexpr int64_t count_microseconds ( std::chrono::microseconds  t)
constexpr

Definition at line 35 of file time.h.

Here is the caller graph for this function:

◆ count_milliseconds()

constexpr int64_t count_milliseconds ( std::chrono::milliseconds  t)
constexpr

Definition at line 32 of file time.h.

Here is the caller graph for this function:

◆ count_seconds()

constexpr int64_t count_seconds ( std::chrono::seconds  t)
constexpr

Helper to count the seconds of a duration.

All durations should be using std::chrono and calling this should generally be avoided in code. Though, it is still preferred to an inline t.count() to protect against a reliance on the exact type of t.

This helper is used to convert durations before passing them over an interface that doesn't support std::chrono (e.g. RPC, debug log, or the GUI)

Definition at line 29 of file time.h.

Here is the caller graph for this function:

◆ CountSecondsDouble()

double CountSecondsDouble ( SecondsDouble  t)
inline

Helper to count the seconds in any std::chrono::duration type.

Definition at line 45 of file time.h.

Here is the caller graph for this function:

◆ FormatISO8601Date()

std::string FormatISO8601Date ( int64_t  nTime)

Definition at line 137 of file time.cpp.

◆ FormatISO8601DateTime()

std::string FormatISO8601DateTime ( int64_t  nTime)

ISO 8601 formatting is preferred.

Use the FormatISO8601{DateTime,Date} helper functions if possible.

Definition at line 122 of file time.cpp.

Here is the caller graph for this function:

◆ GetMockTime()

std::chrono::seconds GetMockTime ( )

For testing.

Definition at line 102 of file time.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetTime()

int64_t GetTime ( )

DEPRECATED Use either GetTimeSeconds (not mockable) or GetTime<T> (mockable)

Return system time (or mocked time, if set)

DEPRECATED Use either GetTimeSeconds (not mockable) or GetTime<T> (mockable)

Definition at line 71 of file time.cpp.

Here is the call graph for this function:

◆ GetTimeMicros()

int64_t GetTimeMicros ( )

Returns the system time (not mockable)

Definition at line 110 of file time.cpp.

Here is the caller graph for this function:

◆ GetTimeMillis()

int64_t GetTimeMillis ( )

Returns the system time (not mockable)

Definition at line 106 of file time.cpp.

Here is the caller graph for this function:

◆ GetTimeSeconds()

int64_t GetTimeSeconds ( )

Returns the system time (not mockable)

Definition at line 114 of file time.cpp.

◆ MillisToTimeval() [1/2]

struct timeval MillisToTimeval ( int64_t  nTimeout)

Convert milliseconds to a struct timeval for e.g.

select.

Definition at line 151 of file time.cpp.

Here is the caller graph for this function:

◆ MillisToTimeval() [2/2]

struct timeval MillisToTimeval ( std::chrono::milliseconds  ms)

Convert milliseconds to a struct timeval for e.g.

select.

Definition at line 151 of file time.cpp.

◆ ParseISO8601DateTime()

int64_t ParseISO8601DateTime ( const std::string &  str)

Definition at line 151 of file time.cpp.

Here is the caller graph for this function:

◆ SetMockTime() [1/2]

void SetMockTime ( int64_t  nMockTimeIn)

DEPRECATED Use SetMockTime with chrono type.

Parameters
[in]nMockTimeInTime in seconds.

Definition at line 94 of file time.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetMockTime() [2/2]

void SetMockTime ( std::chrono::seconds  mock_time_in)

For testing.

Set e.g. with the setmocktime rpc, or -mocktime argument

Definition at line 99 of file time.cpp.

Here is the call graph for this function:

◆ UninterruptibleSleep()

void UninterruptibleSleep ( const std::chrono::microseconds &  n)

Definition at line 23 of file time.cpp.

Here is the caller graph for this function: