Turi Create  4.0
turi::flex_date_time Struct Reference

#include <core/data/flexible_type/flexible_type_base_types.hpp>

Public Member Functions

 flex_date_time (int64_t posix_timestamp, int32_t tz_15min_offset=EMPTY_TIMEZONE, int32_t microsecond=0)
 
int64_t posix_timestamp () const
 
int64_t shifted_posix_timestamp () const
 
void set_posix_timestamp (int64_t ts)
 
double microsecond_res_timestamp () const
 
void set_microsecond_res_timestamp (double d)
 
int32_t microsecond () const
 
void set_microsecond (int32_t microsecond)
 
int32_t time_zone_offset () const
 
void set_time_zone_offset (int32_t tz_15min_offset)
 
bool operator< (const flex_date_time &other) const
 Less than comparator.
 
bool operator> (const flex_date_time &other) const
 Greater than comparator.
 
bool operator== (const flex_date_time &other) const
 Equality comparator, timezone is ignored.
 
bool identical (const flex_date_time &other) const
 Equality comparator, timezone is checked.
 

Static Public Attributes

static constexpr int64_t MICROSECONDS_PER_SECOND = 1000000
 Number of microseconds in 1 second.
 
static constexpr double MICROSECOND_EPSILON = 1.0 / (2 * MICROSECONDS_PER_SECOND)
 
static constexpr int32_t TIMEZONE_LOW = -12 * 4
 lowest value for timezone. 12 hours * 4 (15 min resolution)
 
static constexpr int32_t TIMEZONE_HIGH = 12 * 4
 highest value for timezone. 12 hours * 4 (15 min resolution)
 
static constexpr int32_t EMPTY_TIMEZONE = 64
 Value denoting an invalid timezone.
 
static constexpr int32_t TIMEZONE_RESOLUTION_IN_SECONDS = 15 * 60
 timezone resolution is stored in 15 minute intervals (15*60 seconds)
 
static constexpr int32_t TIMEZONE_RESOLUTION_IN_MINUTES = 15
 timezone resolution is stored in 15 minute intervals (15 minutes)
 
static constexpr double TIMEZONE_RESOLUTION_IN_HOURS = 0.25
 timezone resolution is stored in 15 minute intervals (1/4 hour)
 

Detailed Description

A date_time object that can be stored in a flexible_type. Corresponds to the type enum flex_type_enum::DATETIME flex_date_time.first is utc timestamp and flex_date_time.second is the timezone offset.

Note
Some of the integer oddities done in this struct is to force it to have size 12 bytes so it fits inside a flexible_type

Definition at line 77 of file flexible_type_base_types.hpp.

Constructor & Destructor Documentation

◆ flex_date_time()

turi::flex_date_time::flex_date_time ( int64_t  posix_timestamp,
int32_t  tz_15min_offset = EMPTY_TIMEZONE,
int32_t  microsecond = 0 
)
inlineexplicit

Constructs a flex_date_time object from a posix timestamp, and and time zone offset.

Parameters
posix_timestampTimestamp value since 1st Jan 1970 UTC
tz_15_min_offsetAdditional offset for timezone. In integral increments of 15 minutes. If EMPTY_TIMEZONE, or not provided, there is no timezone information
microsecondMicrosecond value

Definition at line 114 of file flexible_type_base_types.hpp.

Member Function Documentation

◆ microsecond()

int32_t turi::flex_date_time::microsecond ( ) const
inline

Returns the timestamp value.

Definition at line 183 of file flexible_type_base_types.hpp.

◆ microsecond_res_timestamp()

double turi::flex_date_time::microsecond_res_timestamp ( ) const
inline

Returns the timestamp in a floating point value including the microsecond interval.

Note
This function is not generally safe since there are only 52 mantissa bits, We may lose precision for extremely large or extremely small timestamp values

Definition at line 159 of file flexible_type_base_types.hpp.

◆ posix_timestamp()

int64_t turi::flex_date_time::posix_timestamp ( ) const
inline

Returns the timestamp value at UTC

Definition at line 125 of file flexible_type_base_types.hpp.

◆ set_microsecond()

void turi::flex_date_time::set_microsecond ( int32_t  microsecond)
inline

Returns the timestamp value.

Definition at line 190 of file flexible_type_base_types.hpp.

◆ set_microsecond_res_timestamp()

void turi::flex_date_time::set_microsecond_res_timestamp ( double  d)
inline

Sets the timestamp from a floating point value including the microsecond interval.

Note
This function is not generally safe since there are only 52 mantissa bits, We may lose precision for extremely large or extremely small timestamp values

Definition at line 171 of file flexible_type_base_types.hpp.

◆ set_posix_timestamp()

void turi::flex_date_time::set_posix_timestamp ( int64_t  ts)
inline

Sets the posix timestamp value

Definition at line 146 of file flexible_type_base_types.hpp.

◆ set_time_zone_offset()

void turi::flex_date_time::set_time_zone_offset ( int32_t  tz_15min_offset)
inline

Sets the time zone value in integral increments of 15 min

Definition at line 212 of file flexible_type_base_types.hpp.

◆ shifted_posix_timestamp()

int64_t turi::flex_date_time::shifted_posix_timestamp ( ) const
inline

Returns the timestamp value adding the timezone shift

Definition at line 138 of file flexible_type_base_types.hpp.

◆ time_zone_offset()

int32_t turi::flex_date_time::time_zone_offset ( ) const
inline

Returns the time zone value in integral increments of 15 min

Definition at line 200 of file flexible_type_base_types.hpp.

Member Data Documentation

◆ MICROSECOND_EPSILON

constexpr double turi::flex_date_time::MICROSECOND_EPSILON = 1.0 / (2 * MICROSECONDS_PER_SECOND)
static

When doing time comparisons against floating point values, this is the epsilon to use. This is 0.5 microseconds in seconds

Definition at line 83 of file flexible_type_base_types.hpp.


The documentation for this struct was generated from the following file: