23 #include <boost/date_time/posix_time/posix_time_types.hpp>
24 #include <boost/thread/xtime.hpp>
25 #include <boost/version.hpp>
27 #include "mongo/base/status_with.h"
28 #include "mongo/client/export_macros.h"
32 typedef boost::posix_time::milliseconds Milliseconds;
33 typedef boost::posix_time::seconds Seconds;
35 void time_t_to_Struct(time_t t,
struct tm* buf,
bool local =
false);
36 std::string time_t_to_String(time_t t);
37 std::string time_t_to_String_short(time_t t);
41 unsigned long long millis;
43 Date_t(
unsigned long long m) : millis(m) {}
44 operator unsigned long long&() {
47 operator const unsigned long long&()
const {
51 std::string toString()
const;
52 time_t toTimeT()
const;
53 int64_t asInt64()
const {
54 return static_cast<int64_t
>(millis);
56 bool isFormatable()
const;
61 MONGO_CLIENT_API std::string MONGO_CLIENT_FUNC terseCurrentTime(
bool colonsOk =
true);
69 MONGO_CLIENT_API std::string MONGO_CLIENT_FUNC
timeToISOString(time_t time);
120 boost::gregorian::date currentDate();
123 bool toPointInTime(
const std::string& str, boost::posix_time::ptime* timeOfDay);
125 MONGO_CLIENT_API
void MONGO_CLIENT_FUNC sleepsecs(
int s);
126 MONGO_CLIENT_API
void MONGO_CLIENT_FUNC sleepmillis(
long long ms);
127 MONGO_CLIENT_API
void MONGO_CLIENT_FUNC sleepmicros(
long long micros);
131 Backoff(
int maxSleepMillis,
int resetAfter)
132 : _maxSleepMillis(maxSleepMillis),
133 _resetAfterMillis(maxSleepMillis + resetAfter),
135 _lastErrorTimeMillis(0) {}
137 void nextSleepMillis();
143 unsigned long long currTimeMillis,
144 unsigned long long lastErrorTimeMillis)
const;
149 int _resetAfterMillis;
152 int _lastSleepMillis;
153 unsigned long long _lastErrorTimeMillis;
157 void jsTimeVirtualSkew(
long long skew);
159 void jsTimeVirtualThreadSkew(
long long skew);
160 long long getJSTimeVirtualThreadSkew();
167 unsigned long long curTimeMicros64();
168 unsigned long long curTimeMillis64();
171 char* asctime(
const struct tm* tm);
172 char* ctime(
const time_t* timep);
173 struct tm* gmtime(
const time_t* timep);
174 struct tm* localtime(
const time_t* timep);
176 #if (BOOST_VERSION >= 105000)
177 #define MONGO_BOOST_TIME_UTC boost::TIME_UTC_
179 #define MONGO_BOOST_TIME_UTC boost::TIME_UTC
MONGO_CLIENT_API void MONGO_CLIENT_FUNC outputDateAsISOStringLocal(std::ostream &os, Date_t date)
Like dateToISOStringLocal, except outputs to a std::ostream.
A StringData object wraps a 'const string&' or a 'const char*' without copying its contents...
Definition: string_data.h:43
Utility functions for parsing numbers from strings.
Definition: compare_numbers.h:20
MONGO_CLIENT_API void MONGO_CLIENT_FUNC outputDateAsISOStringUTC(std::ostream &os, Date_t date)
Like dateToISOStringUTC, except outputs to a std::ostream.
MONGO_CLIENT_API Date_t MONGO_CLIENT_FUNC jsTime()
Date_t is milliseconds since epoch.
MONGO_CLIENT_API std::string MONGO_CLIENT_FUNC dateToISOStringLocal(Date_t date)
Formats "date" according to the ISO 8601 extended form standard, including date, and time with millis...
MONGO_CLIENT_API StatusWith< Date_t > MONGO_CLIENT_FUNC dateFromISOString(const StringData &dateString)
Parses a Date_t from an ISO 8601 string representation.
Definition: time_support.h:39
MONGO_CLIENT_API void MONGO_CLIENT_FUNC outputDateAsCtime(std::ostream &os, Date_t date)
Like dateToCtimeString, except outputs to a std::ostream.
Definition: status_with.h:43
MONGO_CLIENT_API std::string MONGO_CLIENT_FUNC dateToISOStringUTC(Date_t date)
Formats "date" according to the ISO 8601 extended form standard, including date, and time with millis...
MONGO_CLIENT_API std::string MONGO_CLIENT_FUNC timeToISOString(time_t time)
Formats "time" according to the ISO 8601 extended form standard, including date, and time...
MONGO_CLIENT_API std::string MONGO_CLIENT_FUNC dateToCtimeString(Date_t date)
Formats "date" in fixed width in the local time zone.
Definition: time_support.h:129
unsigned curTimeMicros()
warning this will wrap
int getNextSleepMillis(int lastSleepMillis, unsigned long long currTimeMillis, unsigned long long lastErrorTimeMillis) const
testing-only function.