22
22
#include <boost/thread/xtime.hpp>
23
#include <boost/date_time/posix_time/posix_time.hpp>
23
#include <boost/version.hpp>
25
#include "mongo/bson/util/misc.h" // Date_t
25
#include "mongo/base/status_with.h"
26
#include "mongo/client/export_macros.h"
29
30
void time_t_to_Struct(time_t t, struct tm * buf , bool local = false );
31
std::string time_t_to_String(time_t t);
32
std::string time_t_to_String_short(time_t t);
32
* Gets the current time string (in fixed width) in UTC. Sample format:
34
* Wed Oct 31 13:34:47.996
36
* @param timeStr pointer to the buffer to set the string - should at least be
39
void curTimeString(char* timeStr);
35
// TODO: make signed (and look for related TODO's)
36
unsigned long long millis;
37
Date_t(): millis(0) {}
38
Date_t(unsigned long long m): millis(m) {}
39
operator unsigned long long&() { return millis; }
40
operator const unsigned long long&() const { return millis; }
42
std::string toString() const;
43
time_t toTimeT() const;
44
int64_t asInt64() const {
45
return static_cast<int64_t>(millis);
47
bool isFormatable() const;
41
50
// uses ISO 8601 dates without trailing Z
42
51
// colonsOk should be false when creating filenames
43
52
std::string terseCurrentTime(bool colonsOk=true);
55
* Formats "time" according to the ISO 8601 extended form standard, including date,
56
* and time, in the UTC timezone.
58
* Sample format: "2013-07-23T18:42:14Z"
45
60
std::string timeToISOString(time_t time);
63
* Formats "date" according to the ISO 8601 extended form standard, including date,
64
* and time with milliseconds decimal component, in the UTC timezone.
66
* Sample format: "2013-07-23T18:42:14.072Z"
68
std::string dateToISOStringUTC(Date_t date);
71
* Formats "date" according to the ISO 8601 extended form standard, including date,
72
* and time with milliseconds decimal component, in the local timezone.
74
* Sample format: "2013-07-23T18:42:14.072-05:00"
76
std::string dateToISOStringLocal(Date_t date);
79
* Formats "date" in fixed width in the local time zone.
81
* Sample format: "Wed Oct 31 13:34:47.996"
83
std::string dateToCtimeString(Date_t date);
86
* Parses a Date_t from an ISO 8601 string representation.
88
* Sample formats: "2013-07-23T18:42:14.072-05:00"
89
* "2013-07-23T18:42:14.072Z"
91
* Local times are currently not supported.
93
StatusWith<Date_t> dateFromISOString(const StringData& dateString);
47
95
boost::gregorian::date currentDate();
49
97
// parses time of day in "hh:mm" format assuming 'hh' is 00-23
50
98
bool toPointInTime( const std::string& str , boost::posix_time::ptime* timeOfDay );
52
void sleepsecs(int s);
53
void sleepmillis(long long ms);
54
void sleepmicros(long long micros);
100
MONGO_CLIENT_API void sleepsecs(int s);
101
MONGO_CLIENT_API void sleepmillis(long long ms);
102
MONGO_CLIENT_API void sleepmicros(long long micros);