Split up util.cpp/h
Split up util.cpp/h into:
- string utilities (hex, base32, base64): no internal dependencies, no dependency on boost (apart from foreach)
- money utilities (parsesmoney, formatmoney)
- time utilities (gettime*, sleep, format date):
- and the rest (logging, argument parsing, config file parsing)
The latter is basically the environment and OS handling,
and is stripped of all utility functions, so we may want to
rename it to something else than util.cpp/h for clarity (Matt suggested
osinterface).
Breaks dependency of sha256.cpp on all the things pulled in by util.
2014-08-21 16:11:09 +02:00
|
|
|
// Copyright (c) 2009-2010 Satoshi Nakamoto
|
2019-05-29 13:39:45 +02:00
|
|
|
// Copyright (c) 2009-2019 The Bitcoin Core developers
|
2014-11-17 04:04:01 +01:00
|
|
|
// Distributed under the MIT software license, see the accompanying
|
Split up util.cpp/h
Split up util.cpp/h into:
- string utilities (hex, base32, base64): no internal dependencies, no dependency on boost (apart from foreach)
- money utilities (parsesmoney, formatmoney)
- time utilities (gettime*, sleep, format date):
- and the rest (logging, argument parsing, config file parsing)
The latter is basically the environment and OS handling,
and is stripped of all utility functions, so we may want to
rename it to something else than util.cpp/h for clarity (Matt suggested
osinterface).
Breaks dependency of sha256.cpp on all the things pulled in by util.
2014-08-21 16:11:09 +02:00
|
|
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
|
|
|
2021-06-27 08:33:13 +02:00
|
|
|
#ifndef BITCOIN_UTIL_TIME_H
|
|
|
|
#define BITCOIN_UTIL_TIME_H
|
Split up util.cpp/h
Split up util.cpp/h into:
- string utilities (hex, base32, base64): no internal dependencies, no dependency on boost (apart from foreach)
- money utilities (parsesmoney, formatmoney)
- time utilities (gettime*, sleep, format date):
- and the rest (logging, argument parsing, config file parsing)
The latter is basically the environment and OS handling,
and is stripped of all utility functions, so we may want to
rename it to something else than util.cpp/h for clarity (Matt suggested
osinterface).
Breaks dependency of sha256.cpp on all the things pulled in by util.
2014-08-21 16:11:09 +02:00
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <string>
|
2019-05-29 13:39:45 +02:00
|
|
|
#include <chrono>
|
Split up util.cpp/h
Split up util.cpp/h into:
- string utilities (hex, base32, base64): no internal dependencies, no dependency on boost (apart from foreach)
- money utilities (parsesmoney, formatmoney)
- time utilities (gettime*, sleep, format date):
- and the rest (logging, argument parsing, config file parsing)
The latter is basically the environment and OS handling,
and is stripped of all utility functions, so we may want to
rename it to something else than util.cpp/h for clarity (Matt suggested
osinterface).
Breaks dependency of sha256.cpp on all the things pulled in by util.
2014-08-21 16:11:09 +02:00
|
|
|
|
2017-08-24 01:38:29 +02:00
|
|
|
/**
|
2019-05-29 13:39:45 +02:00
|
|
|
* DEPRECATED
|
|
|
|
* Use either GetSystemTimeInSeconds (not mockable) or GetTime<T> (mockable)
|
2017-08-24 01:38:29 +02:00
|
|
|
*/
|
Split up util.cpp/h
Split up util.cpp/h into:
- string utilities (hex, base32, base64): no internal dependencies, no dependency on boost (apart from foreach)
- money utilities (parsesmoney, formatmoney)
- time utilities (gettime*, sleep, format date):
- and the rest (logging, argument parsing, config file parsing)
The latter is basically the environment and OS handling,
and is stripped of all utility functions, so we may want to
rename it to something else than util.cpp/h for clarity (Matt suggested
osinterface).
Breaks dependency of sha256.cpp on all the things pulled in by util.
2014-08-21 16:11:09 +02:00
|
|
|
int64_t GetTime();
|
2019-05-29 13:39:45 +02:00
|
|
|
|
|
|
|
/** Returns the system time (not mockable) */
|
Split up util.cpp/h
Split up util.cpp/h into:
- string utilities (hex, base32, base64): no internal dependencies, no dependency on boost (apart from foreach)
- money utilities (parsesmoney, formatmoney)
- time utilities (gettime*, sleep, format date):
- and the rest (logging, argument parsing, config file parsing)
The latter is basically the environment and OS handling,
and is stripped of all utility functions, so we may want to
rename it to something else than util.cpp/h for clarity (Matt suggested
osinterface).
Breaks dependency of sha256.cpp on all the things pulled in by util.
2014-08-21 16:11:09 +02:00
|
|
|
int64_t GetTimeMillis();
|
2019-05-29 13:39:45 +02:00
|
|
|
/** Returns the system time (not mockable) */
|
Split up util.cpp/h
Split up util.cpp/h into:
- string utilities (hex, base32, base64): no internal dependencies, no dependency on boost (apart from foreach)
- money utilities (parsesmoney, formatmoney)
- time utilities (gettime*, sleep, format date):
- and the rest (logging, argument parsing, config file parsing)
The latter is basically the environment and OS handling,
and is stripped of all utility functions, so we may want to
rename it to something else than util.cpp/h for clarity (Matt suggested
osinterface).
Breaks dependency of sha256.cpp on all the things pulled in by util.
2014-08-21 16:11:09 +02:00
|
|
|
int64_t GetTimeMicros();
|
2019-05-29 13:39:45 +02:00
|
|
|
/** Returns the system time (not mockable) */
|
2017-08-24 01:38:29 +02:00
|
|
|
int64_t GetSystemTimeInSeconds(); // Like GetTime(), but not mockable
|
2019-05-29 13:39:45 +02:00
|
|
|
|
|
|
|
/** For testing. Set e.g. with the setmocktime rpc, or -mocktime argument */
|
Split up util.cpp/h
Split up util.cpp/h into:
- string utilities (hex, base32, base64): no internal dependencies, no dependency on boost (apart from foreach)
- money utilities (parsesmoney, formatmoney)
- time utilities (gettime*, sleep, format date):
- and the rest (logging, argument parsing, config file parsing)
The latter is basically the environment and OS handling,
and is stripped of all utility functions, so we may want to
rename it to something else than util.cpp/h for clarity (Matt suggested
osinterface).
Breaks dependency of sha256.cpp on all the things pulled in by util.
2014-08-21 16:11:09 +02:00
|
|
|
void SetMockTime(int64_t nMockTimeIn);
|
2019-05-29 13:39:45 +02:00
|
|
|
/** For testing */
|
2017-05-16 08:06:26 +02:00
|
|
|
int64_t GetMockTime();
|
2019-05-29 13:39:45 +02:00
|
|
|
|
Split up util.cpp/h
Split up util.cpp/h into:
- string utilities (hex, base32, base64): no internal dependencies, no dependency on boost (apart from foreach)
- money utilities (parsesmoney, formatmoney)
- time utilities (gettime*, sleep, format date):
- and the rest (logging, argument parsing, config file parsing)
The latter is basically the environment and OS handling,
and is stripped of all utility functions, so we may want to
rename it to something else than util.cpp/h for clarity (Matt suggested
osinterface).
Breaks dependency of sha256.cpp on all the things pulled in by util.
2014-08-21 16:11:09 +02:00
|
|
|
void MilliSleep(int64_t n);
|
|
|
|
|
2019-05-29 13:39:45 +02:00
|
|
|
/** Return system time (or mocked time, if set) */
|
|
|
|
template <typename T>
|
|
|
|
T GetTime();
|
|
|
|
|
2018-03-10 14:08:15 +01:00
|
|
|
/**
|
|
|
|
* ISO 8601 formatting is preferred. Use the FormatISO8601{DateTime,Date,Time}
|
|
|
|
* helper functions if possible.
|
|
|
|
*/
|
|
|
|
std::string FormatISO8601DateTime(int64_t nTime);
|
|
|
|
std::string FormatISO8601Date(int64_t nTime);
|
|
|
|
std::string FormatISO8601Time(int64_t nTime);
|
|
|
|
|
2021-06-27 08:33:13 +02:00
|
|
|
#endif // BITCOIN_UTIL_TIME_H
|