Bitcoin Core  0.19.99
P2P Digital Currency
time.h
Go to the documentation of this file.
1 // Copyright (c) 2009-2010 Satoshi Nakamoto
2 // Copyright (c) 2009-2019 The Bitcoin Core developers
3 // Distributed under the MIT software license, see the accompanying
4 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
5 
6 #ifndef BITCOIN_UTIL_TIME_H
7 #define BITCOIN_UTIL_TIME_H
8 
9 #include <stdint.h>
10 #include <string>
11 #include <chrono>
12 
19 inline int64_t count_seconds(std::chrono::seconds t) { return t.count(); }
20 
25 int64_t GetTime();
26 
28 int64_t GetTimeMillis();
30 int64_t GetTimeMicros();
32 int64_t GetSystemTimeInSeconds(); // Like GetTime(), but not mockable
33 
35 void SetMockTime(int64_t nMockTimeIn);
37 int64_t GetMockTime();
38 
39 void MilliSleep(int64_t n);
40 
42 template <typename T>
43 T GetTime();
44 
49 std::string FormatISO8601DateTime(int64_t nTime);
50 std::string FormatISO8601Date(int64_t nTime);
51 int64_t ParseISO8601DateTime(const std::string& str);
52 
53 #endif // BITCOIN_UTIL_TIME_H
int64_t GetSystemTimeInSeconds()
Returns the system time (not mockable)
Definition: time.cpp:70
int64_t count_seconds(std::chrono::seconds t)
Helper to count the seconds of a duration.
Definition: time.h:19
int64_t GetTime()
DEPRECATED Use either GetSystemTimeInSeconds (not mockable) or GetTime<T> (mockable) ...
Definition: time.cpp:20
int64_t GetTimeMillis()
Returns the system time (not mockable)
Definition: time.cpp:54
int64_t GetMockTime()
For testing.
Definition: time.cpp:49
int64_t ParseISO8601DateTime(const std::string &str)
Definition: time.cpp:115
std::string FormatISO8601Date(int64_t nTime)
Definition: time.cpp:104
std::string FormatISO8601DateTime(int64_t nTime)
ISO 8601 formatting is preferred.
Definition: time.cpp:93
void SetMockTime(int64_t nMockTimeIn)
For testing.
Definition: time.cpp:44
void MilliSleep(int64_t n)
Definition: time.cpp:75
int64_t GetTimeMicros()
Returns the system time (not mockable)
Definition: time.cpp:62