Bitcoin ABC  0.24.7
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 <chrono>
10 #include <cstdint>
11 #include <string>
12 
13 void UninterruptibleSleep(const std::chrono::microseconds &n);
14 
25 inline int64_t count_seconds(std::chrono::seconds t) {
26  return t.count();
27 }
28 inline int64_t count_microseconds(std::chrono::microseconds t) {
29  return t.count();
30 }
31 
36 int64_t GetTime();
37 
39 int64_t GetTimeMillis();
41 int64_t GetTimeMicros();
43 // Like GetTime(), but not mockable
44 int64_t GetSystemTimeInSeconds();
45 
47 void SetMockTime(int64_t nMockTimeIn);
49 int64_t GetMockTime();
50 
52 template <typename T> T GetTime();
53 
58 std::string FormatISO8601DateTime(int64_t nTime);
59 std::string FormatISO8601Date(int64_t nTime);
60 int64_t ParseISO8601DateTime(const std::string &str);
61 
62 #endif // BITCOIN_UTIL_TIME_H
UninterruptibleSleep
void UninterruptibleSleep(const std::chrono::microseconds &n)
Definition: time.cpp:20
SetMockTime
void SetMockTime(int64_t nMockTimeIn)
For testing.
Definition: time.cpp:50
FormatISO8601Date
std::string FormatISO8601Date(int64_t nTime)
Definition: time.cpp:94
count_seconds
int64_t count_seconds(std::chrono::seconds t)
Helper to count the seconds of a duration.
Definition: time.h:25
ParseISO8601DateTime
int64_t ParseISO8601DateTime(const std::string &str)
Definition: time.cpp:108
GetTimeMillis
int64_t GetTimeMillis()
Returns the system time (not mockable)
Definition: time.cpp:59
count_microseconds
int64_t count_microseconds(std::chrono::microseconds t)
Definition: time.h:28
GetSystemTimeInSeconds
int64_t GetSystemTimeInSeconds()
Returns the system time (not mockable)
Definition: time.cpp:75
GetMockTime
int64_t GetMockTime()
For testing.
Definition: time.cpp:55
GetTimeMicros
int64_t GetTimeMicros()
Returns the system time (not mockable)
Definition: time.cpp:67
FormatISO8601DateTime
std::string FormatISO8601DateTime(int64_t nTime)
ISO 8601 formatting is preferred.
Definition: time.cpp:79
GetTime
int64_t GetTime()
DEPRECATED Use either GetSystemTimeInSeconds (not mockable) or GetTime<T> (mockable)
Definition: time.cpp:27