Bitcoin Core  0.20.99
P2P Digital Currency
time.h
Go to the documentation of this file.
1 // Copyright (c) 2009-2010 Satoshi Nakamoto
2 // Copyright (c) 2009-2020 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 
13 void UninterruptibleSleep(const std::chrono::microseconds& n);
14 
21 inline int64_t count_seconds(std::chrono::seconds t) { return t.count(); }
22 
27 int64_t GetTime();
28 
30 int64_t GetTimeMillis();
32 int64_t GetTimeMicros();
34 int64_t GetSystemTimeInSeconds(); // Like GetTime(), but not mockable
35 
37 void SetMockTime(int64_t nMockTimeIn);
39 int64_t GetMockTime();
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:73
void UninterruptibleSleep(const std::chrono::microseconds &n)
Definition: time.cpp:19
int64_t count_seconds(std::chrono::seconds t)
Helper to count the seconds of a duration.
Definition: time.h:21
int64_t GetTime()
DEPRECATED Use either GetSystemTimeInSeconds (not mockable) or GetTime<T> (mockable) ...
Definition: time.cpp:23
int64_t GetTimeMillis()
Returns the system time (not mockable)
Definition: time.cpp:57
int64_t GetMockTime()
For testing.
Definition: time.cpp:52
int64_t ParseISO8601DateTime(const std::string &str)
Definition: time.cpp:104
std::string FormatISO8601Date(int64_t nTime)
Definition: time.cpp:91
std::string FormatISO8601DateTime(int64_t nTime)
ISO 8601 formatting is preferred.
Definition: time.cpp:78
void SetMockTime(int64_t nMockTimeIn)
For testing.
Definition: time.cpp:47
int64_t GetTimeMicros()
Returns the system time (not mockable)
Definition: time.cpp:65