inline FLEX_ALWAYS_INLINE_FLATTEN void operator()(flex_date_time& t, const flex_float u) const { int64_t integral_part = std::floor(u); int64_t us_part = (u - integral_part) * flex_date_time::MICROSECONDS_PER_SECOND; t.set_posix_timestamp(t.posix_timestamp() - integral_part); auto microsecond = t.microsecond() - us_part; if (microsecond < 0) { t.set_posix_timestamp(t.posix_timestamp() - 1); microsecond += flex_date_time::MICROSECONDS_PER_SECOND; } t.set_microsecond(microsecond); }
static void _to_serializable(flexible_type& data, schema_t& schema, const flex_date_time& input) { schema.insert(std::make_pair("type", JSON::types::DATETIME)); flex_dict ret; int32_t time_zone_offset = input.time_zone_offset(); ret.push_back(std::make_pair("posix_timestamp", input.posix_timestamp())); ret.push_back(std::make_pair("tz_15_min_offset", time_zone_offset == 64 ? FLEX_UNDEFINED : flexible_type(flex_int(time_zone_offset)))); ret.push_back(std::make_pair("microsecond", input.microsecond())); data = ret; }
/// Equality comparator, timezone is checked inline bool identical(const flex_date_time& other) const{ return posix_timestamp() == other.posix_timestamp() && time_zone_offset() == other.time_zone_offset() && microsecond() == other.microsecond(); }
/// Equality comparator, timezone is ignored. inline bool operator==(const flex_date_time& other) const{ return posix_timestamp() == other.posix_timestamp() && microsecond() == other.microsecond(); }
inline FLEX_ALWAYS_INLINE_FLATTEN bool operator()(const flex_int t, const flex_date_time u) const { return t == u.posix_timestamp() && u.microsecond() == 0; }