drizzle
C++ MySQL-protocol-compatible database server
Loading...
Searching...
No Matches
drizzled::TemporalInterval Class Reference

Stores time interval for date/time manipulation. More...

#include <temporal_interval.h>

Public Member Functions

 TemporalInterval (uint32_t in_year, uint32_t in_month, uint32_t in_day, uint32_t in_hour, uint64_t in_minute, uint64_t in_second, uint64_t in_second_part, bool in_neg)
void setNegative (bool in_neg=true)
void toggleNegative ()
bool getNegative () const
uint32_t get_year () const
void set_year (uint32_t new_year)
uint32_t get_month () const
void set_month (uint32_t new_month)
uint32_t get_day () const
void set_day (uint32_t new_day)
uint32_t get_hour () const
void set_hour (uint32_t new_hour)
uint64_t get_minute () const
void set_minute (uint32_t new_minute)
uint64_t get_second () const
void set_second (uint32_t new_second)
uint64_t get_second_part () const
void set_second_part (uint32_t new_second_part)
bool initFromItem (Item *args, interval_type int_type, String *str_value)
bool addDate (type::Time *ltime, interval_type int_type)

Private Member Functions

bool getIntervalFromString (const char *str, uint32_t length, const charset_info_st *const cs, uint32_t count, uint64_t *values, bool transform_msec)

Private Attributes

uint32_t year
uint32_t month
uint32_t day
uint32_t hour
uint64_t minute
uint64_t second
uint64_t second_part
bool neg

Static Private Attributes

static const uint32_t MAX_STRING_ELEMENTS = 5
static const uint32_t NUM_YEAR_MONTH_STRING_ELEMENTS = 2
static const uint32_t NUM_DAY_HOUR_STRING_ELEMENTS = 2
static const uint32_t NUM_DAY_MICROSECOND_STRING_ELEMENTS = 5
static const uint32_t NUM_DAY_MINUTE_STRING_ELEMENTS = 3
static const uint32_t NUM_DAY_SECOND_STRING_ELEMENTS = 4
static const uint32_t NUM_HOUR_MICROSECOND_STRING_ELEMENTS = 4
static const uint32_t NUM_HOUR_MINUTE_STRING_ELEMENTS = 2
static const uint32_t NUM_HOUR_SECOND_STRING_ELEMENTS = 3
static const uint32_t NUM_MINUTE_MICROSECOND_STRING_ELEMENTS = 3
static const uint32_t NUM_MINUTE_SECOND_STRING_ELEMENTS = 2
static const uint32_t NUM_SECOND_MICROSECOND_STRING_ELEMENTS = 2

Detailed Description

Stores time interval for date/time manipulation.

Definition at line 36 of file temporal_interval.h.

Constructor & Destructor Documentation

◆ TemporalInterval() [1/2]

drizzled::TemporalInterval::TemporalInterval ( uint32_t in_year,
uint32_t in_month,
uint32_t in_day,
uint32_t in_hour,
uint64_t in_minute,
uint64_t in_second,
uint64_t in_second_part,
bool in_neg )
inline

Definition at line 40 of file temporal_interval.h.

◆ TemporalInterval() [2/2]

drizzled::TemporalInterval::TemporalInterval ( )
inline

Definition at line 58 of file temporal_interval.h.

Member Function Documentation

◆ addDate()

bool drizzled::TemporalInterval::addDate ( type::Time * ltime,
interval_type int_type )

Adds this interval to a DRIZZLE_LTIME structure

Parameters
[in,out]ltimethe interval will be added to ltime directly in the ltime structure
[in]int_typethe type of interval requested
Return values
truedate was added and value stored properly
falseresult of addition is a null value

Definition at line 190 of file temporal_interval.cc.

◆ get_day()

uint32_t drizzled::TemporalInterval::get_day ( ) const
inline

Definition at line 101 of file temporal_interval.h.

◆ get_hour()

uint32_t drizzled::TemporalInterval::get_hour ( ) const
inline

Definition at line 104 of file temporal_interval.h.

◆ get_minute()

uint64_t drizzled::TemporalInterval::get_minute ( ) const
inline

Definition at line 107 of file temporal_interval.h.

◆ get_month()

uint32_t drizzled::TemporalInterval::get_month ( ) const
inline

Definition at line 98 of file temporal_interval.h.

◆ get_second()

uint64_t drizzled::TemporalInterval::get_second ( ) const
inline

Definition at line 110 of file temporal_interval.h.

◆ get_second_part()

uint64_t drizzled::TemporalInterval::get_second_part ( ) const
inline

Definition at line 113 of file temporal_interval.h.

◆ get_year()

uint32_t drizzled::TemporalInterval::get_year ( ) const
inline

Definition at line 95 of file temporal_interval.h.

◆ getIntervalFromString()

bool drizzled::TemporalInterval::getIntervalFromString ( const char * str,
uint32_t length,
const charset_info_st *const cs,
uint32_t count,
uint64_t * values,
bool transform_msec )
private

Get a array of positive numbers from a string object. Each number is separated by 1 non digit character Return error if there is too many numbers. If there is too few numbers, assume that the numbers are left out from the high end. This allows one to give: DAY_TO_SECOND as "D MM:HH:SS", "MM:HH:SS" "HH:SS" or as seconds.

Parameters
[in]lengthlength of str
[in]cscharset of str
[out]valuesarray of results
[out]countcount of elements in result array
transform_msecif value is true we suppose that the last part of string value is microseconds and we should transform value to six digit value. For example, '1.1' -> '1.100000'

Definition at line 296 of file temporal_interval.cc.

◆ getNegative()

bool drizzled::TemporalInterval::getNegative ( ) const
inline
Return values
truethis is a negative temporal interval
falsethis is a positive temporal interval

Definition at line 90 of file temporal_interval.h.

◆ initFromItem()

bool drizzled::TemporalInterval::initFromItem ( Item * args,
interval_type int_type,
String * str_value )

Populate this TemporalInterval from a string value

To make code easy, allow interval objects without separators.

Parameters
argsargument Item structure
int_typetype of interval to create
str_valueString pointer to the input value
Returns
true if the string would result in a null interval

Definition at line 33 of file temporal_interval.cc.

◆ set_day()

void drizzled::TemporalInterval::set_day ( uint32_t new_day)
inline

Definition at line 102 of file temporal_interval.h.

◆ set_hour()

void drizzled::TemporalInterval::set_hour ( uint32_t new_hour)
inline

Definition at line 105 of file temporal_interval.h.

◆ set_minute()

void drizzled::TemporalInterval::set_minute ( uint32_t new_minute)
inline

Definition at line 108 of file temporal_interval.h.

◆ set_month()

void drizzled::TemporalInterval::set_month ( uint32_t new_month)
inline

Definition at line 99 of file temporal_interval.h.

◆ set_second()

void drizzled::TemporalInterval::set_second ( uint32_t new_second)
inline

Definition at line 111 of file temporal_interval.h.

◆ set_second_part()

void drizzled::TemporalInterval::set_second_part ( uint32_t new_second_part)
inline

Definition at line 114 of file temporal_interval.h.

◆ set_year()

void drizzled::TemporalInterval::set_year ( uint32_t new_year)
inline

Definition at line 96 of file temporal_interval.h.

◆ setNegative()

void drizzled::TemporalInterval::setNegative ( bool in_neg = true)
inline

Sets whether or not this object specifies a negative interval

Parameters
[in]in_negtrue if this is a negative interval, false if not

Definition at line 73 of file temporal_interval.h.

◆ toggleNegative()

void drizzled::TemporalInterval::toggleNegative ( )
inline

reverse boolean value of the negative flag

Definition at line 81 of file temporal_interval.h.

Member Data Documentation

◆ day

uint32_t drizzled::TemporalInterval::day
private

Definition at line 188 of file temporal_interval.h.

◆ hour

uint32_t drizzled::TemporalInterval::hour
private

Definition at line 189 of file temporal_interval.h.

◆ MAX_STRING_ELEMENTS

const uint32_t drizzled::TemporalInterval::MAX_STRING_ELEMENTS = 5
staticprivate

The maximum number of text elements to extract into a temporal interval

Definition at line 144 of file temporal_interval.h.

◆ minute

uint64_t drizzled::TemporalInterval::minute
private

Definition at line 190 of file temporal_interval.h.

◆ month

uint32_t drizzled::TemporalInterval::month
private

Definition at line 187 of file temporal_interval.h.

◆ neg

bool drizzled::TemporalInterval::neg
private

Definition at line 193 of file temporal_interval.h.

◆ NUM_DAY_HOUR_STRING_ELEMENTS

const uint32_t drizzled::TemporalInterval::NUM_DAY_HOUR_STRING_ELEMENTS = 2
staticprivate

Definition at line 150 of file temporal_interval.h.

◆ NUM_DAY_MICROSECOND_STRING_ELEMENTS

const uint32_t drizzled::TemporalInterval::NUM_DAY_MICROSECOND_STRING_ELEMENTS = 5
staticprivate

Definition at line 151 of file temporal_interval.h.

◆ NUM_DAY_MINUTE_STRING_ELEMENTS

const uint32_t drizzled::TemporalInterval::NUM_DAY_MINUTE_STRING_ELEMENTS = 3
staticprivate

Definition at line 152 of file temporal_interval.h.

◆ NUM_DAY_SECOND_STRING_ELEMENTS

const uint32_t drizzled::TemporalInterval::NUM_DAY_SECOND_STRING_ELEMENTS = 4
staticprivate

Definition at line 153 of file temporal_interval.h.

◆ NUM_HOUR_MICROSECOND_STRING_ELEMENTS

const uint32_t drizzled::TemporalInterval::NUM_HOUR_MICROSECOND_STRING_ELEMENTS = 4
staticprivate

Definition at line 154 of file temporal_interval.h.

◆ NUM_HOUR_MINUTE_STRING_ELEMENTS

const uint32_t drizzled::TemporalInterval::NUM_HOUR_MINUTE_STRING_ELEMENTS = 2
staticprivate

Definition at line 155 of file temporal_interval.h.

◆ NUM_HOUR_SECOND_STRING_ELEMENTS

const uint32_t drizzled::TemporalInterval::NUM_HOUR_SECOND_STRING_ELEMENTS = 3
staticprivate

Definition at line 156 of file temporal_interval.h.

◆ NUM_MINUTE_MICROSECOND_STRING_ELEMENTS

const uint32_t drizzled::TemporalInterval::NUM_MINUTE_MICROSECOND_STRING_ELEMENTS = 3
staticprivate

Definition at line 157 of file temporal_interval.h.

◆ NUM_MINUTE_SECOND_STRING_ELEMENTS

const uint32_t drizzled::TemporalInterval::NUM_MINUTE_SECOND_STRING_ELEMENTS = 2
staticprivate

Definition at line 158 of file temporal_interval.h.

◆ NUM_SECOND_MICROSECOND_STRING_ELEMENTS

const uint32_t drizzled::TemporalInterval::NUM_SECOND_MICROSECOND_STRING_ELEMENTS = 2
staticprivate

Definition at line 159 of file temporal_interval.h.

◆ NUM_YEAR_MONTH_STRING_ELEMENTS

const uint32_t drizzled::TemporalInterval::NUM_YEAR_MONTH_STRING_ELEMENTS = 2
staticprivate

Each of these corresponds to an 'interval_type'

Definition at line 149 of file temporal_interval.h.

◆ second

uint64_t drizzled::TemporalInterval::second
private

Definition at line 191 of file temporal_interval.h.

◆ second_part

uint64_t drizzled::TemporalInterval::second_part
private

Definition at line 192 of file temporal_interval.h.

◆ year

uint32_t drizzled::TemporalInterval::year
private

Definition at line 186 of file temporal_interval.h.


The documentation for this class was generated from the following files: