mongodb插入datetime类型所用函数appendDate的参数Date_t详解

源码:

struct MONGO_CLIENT_API Date_t {
     // TODO: make signed (and look for related TODO's)
     unsigned long long millis;
     Date_t() : millis(0) {}
     Date_t(unsigned long long m) : millis(m) {}
     operator unsigned long long&() {
         return millis;
     }
     operator const unsigned long long&() c    {
         return millis;
     }
     void toTm(tm* buf);
     std::string toString() const;
     time_t toTimeT() const;
     int64_t asInt64() const {
         return static_cast(millis);
     }
     bool isFormatable() const;
};

需要注意的是Date_t(unsigned long long m)的输入一定是毫秒级别的时间戳,否则得到的Date_t有错误

你可能感兴趣的:(有关学习)