You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

utiltime.h 1.1KB

1234567891011121314151617181920212223242526272829303132
  1. // Copyright (c) 2009-2010 Satoshi Nakamoto
  2. // Copyright (c) 2009-2015 The Starwels developers
  3. // Distributed under the MIT software license, see the accompanying
  4. // file COPYING or http://www.opensource.org/licenses/mit-license.php.
  5. #ifndef STARWELS_UTILTIME_H
  6. #define STARWELS_UTILTIME_H
  7. #include <stdint.h>
  8. #include <string>
  9. /**
  10. * GetTimeMicros() and GetTimeMillis() both return the system time, but in
  11. * different units. GetTime() returns the system time in seconds, but also
  12. * supports mocktime, where the time can be specified by the user, eg for
  13. * testing (eg with the setmocktime rpc, or -mocktime argument).
  14. *
  15. * TODO: Rework these functions to be type-safe (so that we don't inadvertently
  16. * compare numbers with different units, or compare a mocktime to system time).
  17. */
  18. int64_t GetTime();
  19. int64_t GetTimeMillis();
  20. int64_t GetTimeMicros();
  21. int64_t GetSystemTimeInSeconds(); // Like GetTime(), but not mockable
  22. void SetMockTime(int64_t nMockTimeIn);
  23. int64_t GetMockTime();
  24. void MilliSleep(int64_t n);
  25. std::string DateTimeStrFormat(const char* pszFormat, int64_t nTime);
  26. #endif // STARWELS_UTILTIME_H