Bitcoin ABC  0.22.13
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 
22 inline int64_t count_seconds(std::chrono::seconds t) {
23  return t.count();
24 }
25 
30 int64_t GetTime();
31 
33 int64_t GetTimeMillis();
35 int64_t GetTimeMicros();
37 // Like GetTime(), but not mockable
38 int64_t GetSystemTimeInSeconds();
39 
41 void SetMockTime(int64_t nMockTimeIn);
43 int64_t GetMockTime();
44 
46 template <typename T> T GetTime();
47 
52 std::string FormatISO8601DateTime(int64_t nTime);
53 std::string FormatISO8601Date(int64_t nTime);
54 int64_t ParseISO8601DateTime(const std::string &str);
55 
56 #endif // BITCOIN_UTIL_TIME_H
int64_t GetSystemTimeInSeconds()
Returns the system time (not mockable)
Definition: time.cpp:75
void UninterruptibleSleep(const std::chrono::microseconds &n)
Definition: time.cpp:20
int64_t count_seconds(std::chrono::seconds t)
Helper to count the seconds of a duration.
Definition: time.h:22
int64_t GetTime()
DEPRECATED Use either GetSystemTimeInSeconds (not mockable) or GetTime<T> (mockable) ...
Definition: time.cpp:27
int64_t GetTimeMillis()
Returns the system time (not mockable)
Definition: time.cpp:59
int64_t GetMockTime()
For testing.
Definition: time.cpp:55
int64_t ParseISO8601DateTime(const std::string &str)
Definition: time.cpp:108
std::string FormatISO8601Date(int64_t nTime)
Definition: time.cpp:94
std::string FormatISO8601DateTime(int64_t nTime)
ISO 8601 formatting is preferred.
Definition: time.cpp:79
void SetMockTime(int64_t nMockTimeIn)
For testing.
Definition: time.cpp:50
int64_t GetTimeMicros()
Returns the system time (not mockable)
Definition: time.cpp:67