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&() {
return millis; }
45 operator const unsigned long long&()
const {
return millis; }
47 std::string toString()
const;
48 time_t toTimeT()
const;
49 int64_t asInt64()
const {
50 return static_cast<int64_t
>(millis);
52 bool isFormatable()
const;
57 MONGO_CLIENT_API std::string MONGO_CLIENT_FUNC terseCurrentTime(
bool colonsOk=
true);
115 boost::gregorian::date currentDate();
118 bool toPointInTime(
const std::string& str , boost::posix_time::ptime* timeOfDay );
120 MONGO_CLIENT_API
void MONGO_CLIENT_FUNC sleepsecs(
int s);
121 MONGO_CLIENT_API
void MONGO_CLIENT_FUNC sleepmillis(
long long ms);
122 MONGO_CLIENT_API
void MONGO_CLIENT_FUNC sleepmicros(
long long micros);
127 Backoff(
int maxSleepMillis,
int resetAfter ) :
128 _maxSleepMillis( maxSleepMillis ),
129 _resetAfterMillis( maxSleepMillis + resetAfter ),
130 _lastSleepMillis( 0 ),
131 _lastErrorTimeMillis( 0 )
134 void nextSleepMillis();
140 unsigned long long lastErrorTimeMillis)
const;
146 int _resetAfterMillis;
149 int _lastSleepMillis;
150 unsigned long long _lastErrorTimeMillis;
154 void jsTimeVirtualSkew(
long long skew );
156 void jsTimeVirtualThreadSkew(
long long skew );
157 long long getJSTimeVirtualThreadSkew();
164 unsigned long long curTimeMicros64();
165 unsigned long long curTimeMillis64();
168 char *asctime(
const struct tm *tm);
169 char *ctime(
const time_t *timep);
170 struct tm *gmtime(
const time_t *timep);
171 struct tm *localtime(
const time_t *timep);
173#if (BOOST_VERSION >= 105000)
174#define MONGO_BOOST_TIME_UTC boost::TIME_UTC_
176#define MONGO_BOOST_TIME_UTC boost::TIME_UTC
Definition time_support.h:124
int getNextSleepMillis(int lastSleepMillis, unsigned long long currTimeMillis, unsigned long long lastErrorTimeMillis) const
testing-only function.
Definition sasl_client_conversation.h:27
the main MongoDB namespace
Definition bulk_operation_builder.h:24
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.
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 void MONGO_CLIENT_FUNC outputDateAsISOStringUTC(std::ostream &os, Date_t date)
Like dateToISOStringUTC, except outputs to a std::ostream.
MONGO_CLIENT_API StatusWith< Date_t > MONGO_CLIENT_FUNC dateFromISOString(const StringData &dateString)
Parses a Date_t from an ISO 8601 string representation.
MONGO_CLIENT_API Date_t MONGO_CLIENT_FUNC jsTime()
Date_t is milliseconds since epoch.
MONGO_CLIENT_API void MONGO_CLIENT_FUNC outputDateAsISOStringLocal(std::ostream &os, Date_t date)
Like dateToISOStringLocal, except outputs to a std::ostream.
unsigned curTimeMicros()
warning this will wrap
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 void MONGO_CLIENT_FUNC outputDateAsCtime(std::ostream &os, Date_t date)
Like dateToCtimeString, except outputs to a std::ostream.
Definition time_support.h:39