Bitcoin Core  21.99.0
P2P Digital Currency
Functions
time.cpp File Reference
#include <compat.h>
#include <util/time.h>
#include <util/check.h>
#include <atomic>
#include <boost/date_time/posix_time/posix_time.hpp>
#include <ctime>
#include <thread>
#include <tinyformat.h>
Include dependency graph for time.cpp:

Go to the source code of this file.

Functions

void UninterruptibleSleep (const std::chrono::microseconds &n)
 
static std::atomic< int64_t > nMockTime (0)
 For testing. More...
 
int64_t GetTime ()
 DEPRECATED Use either GetSystemTimeInSeconds (not mockable) or GetTime<T> (mockable) More...
 
bool ChronoSanityCheck ()
 Sanity check epoch match normal Unix epoch. More...
 
template<typename T >
static T GetSystemTime ()
 
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...
 
int64_t GetTimeMillis ()
 Returns the system time (not mockable) More...
 
int64_t GetTimeMicros ()
 Returns the system time (not mockable) More...
 
int64_t GetSystemTimeInSeconds ()
 Returns the system time (not mockable) 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...
 

Function Documentation

◆ ChronoSanityCheck()

bool ChronoSanityCheck ( )

Sanity check epoch match normal Unix epoch.

Definition at line 36 of file time.cpp.

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

◆ FormatISO8601Date()

std::string FormatISO8601Date ( int64_t  nTime)

Definition at line 145 of file time.cpp.

Here is the caller graph for this function:

◆ FormatISO8601DateTime()

std::string FormatISO8601DateTime ( int64_t  nTime)

ISO 8601 formatting is preferred.

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

Definition at line 132 of file time.cpp.

Here is the caller graph for this function:

◆ GetMockTime()

std::chrono::seconds GetMockTime ( )

For testing.

Definition at line 112 of file time.cpp.

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

◆ GetSystemTime()

template<typename T >
static T GetSystemTime ( )
static

Definition at line 94 of file time.cpp.

Here is the call graph for this function:

◆ GetSystemTimeInSeconds()

int64_t GetSystemTimeInSeconds ( )

Returns the system time (not mockable)

Definition at line 127 of file time.cpp.

Here is the caller graph for this function:

◆ GetTime()

template std::chrono::microseconds GetTime ( )

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

Return system time (or mocked time, if set)

Definition at line 26 of file time.cpp.

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

◆ GetTimeMicros()

int64_t GetTimeMicros ( )

Returns the system time (not mockable)

Definition at line 122 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 117 of file time.cpp.

Here is the caller graph for this function:

◆ MillisToTimeval() [1/2]

struct timeval MillisToTimeval ( int64_t  nTimeout)

Convert milliseconds to a struct timeval for e.g.

select.

Definition at line 172 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 180 of file time.cpp.

Here is the call graph for this function:

◆ nMockTime()

static std::atomic<int64_t> nMockTime ( )
static

For testing.

Here is the caller graph for this function:

◆ ParseISO8601DateTime()

int64_t ParseISO8601DateTime ( const std::string &  str)

Definition at line 158 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 101 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 107 of file time.cpp.

Here is the call graph for this function:

◆ UninterruptibleSleep()

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

Definition at line 22 of file time.cpp.

Here is the caller graph for this function: