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 () |
void | set_year (uint32_t new_year) |
uint32_t | get_month () |
void | set_month (uint32_t new_month) |
uint32_t | get_day () |
void | set_day (uint32_t new_day) |
uint32_t | get_hour () |
void | set_hour (uint32_t new_hour) |
uint64_t | get_minute () |
void | set_minute (uint32_t new_minute) |
uint64_t | get_second () |
void | set_second (uint32_t new_second) |
uint64_t | get_second_part () |
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 *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 |
Stores time interval for date/time manipulation.
Definition at line 37 of file temporal_interval.h.
bool drizzled::TemporalInterval::addDate | ( | type::Time * | ltime, |
interval_type | int_type | ||
) |
Adds this interval to a DRIZZLE_LTIME structure
[in,out] | ltime | the interval will be added to ltime directly in the ltime structure |
[in] | int_type | the type of interval requested |
true | date was added and value stored properly |
false | result of addition is a null value |
Definition at line 190 of file temporal_interval.cc.
Referenced by drizzled::Item_date_add_interval::get_date().
bool drizzled::TemporalInterval::getIntervalFromString | ( | const char * | str, |
uint32_t | length, | ||
const CHARSET_INFO *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.
[in] | length,: | length of str |
[in] | cs,: | charset of str |
[out] | values,: | array of results |
[out] | count,: | count of elements in result array |
transform_msec,: | if 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.
Referenced by initFromItem().
bool drizzled::TemporalInterval::getNegative | ( | ) | const [inline] |
true | this is a negative temporal interval |
false | this is a positive temporal interval |
Definition at line 91 of file temporal_interval.h.
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.
args | argument Item structure |
int_type | type of interval to create |
str_value | String pointer to the input value |
Definition at line 33 of file temporal_interval.cc.
References getIntervalFromString(), MAX_STRING_ELEMENTS, drizzled::Item::null_value, NUM_YEAR_MONTH_STRING_ELEMENTS, drizzled::Item::val_int(), and drizzled::Item::val_str().
Referenced by drizzled::Item_date_add_interval::get_date().
void drizzled::TemporalInterval::setNegative | ( | bool | in_neg = true | ) | [inline] |
Sets whether or not this object specifies a negative interval
[in] | in_neg | true if this is a negative interval, false if not |
Definition at line 74 of file temporal_interval.h.
void drizzled::TemporalInterval::toggleNegative | ( | ) | [inline] |
reverse boolean value of the negative flag
Definition at line 82 of file temporal_interval.h.
Referenced by drizzled::Item_date_add_interval::get_date().
const uint32_t drizzled::TemporalInterval::MAX_STRING_ELEMENTS = 5 [static, private] |
The maximum number of text elements to extract into a temporal interval
Definition at line 145 of file temporal_interval.h.
Referenced by initFromItem().
const uint32_t drizzled::TemporalInterval::NUM_YEAR_MONTH_STRING_ELEMENTS = 2 [static, private] |
Each of these corresponds to an 'interval_type'
Definition at line 150 of file temporal_interval.h.
Referenced by initFromItem().