147
147
bool Date::from_string(const char *from, size_t from_len)
150
* Loop through the known date formats and see if
154
TemporalFormat *current_format;
155
std::vector<TemporalFormat *>::iterator current= known_date_formats.begin();
157
149
_useconds= 0; // We may not match on it, so we need to make sure we zero it out.
158
while (current != known_date_formats.end())
150
BOOST_FOREACH(TemporalFormat* it, known_date_formats)
160
current_format= *current;
161
if (current_format->matches(from, from_len, this))
152
if (not it->matches(from, from_len, this))
176
160
bool DateTime::from_string(const char *from, size_t from_len)
179
* Loop through the known datetime formats and see if
183
TemporalFormat *current_format;
184
std::vector<TemporalFormat *>::iterator current= known_datetime_formats.begin();
186
while (current != known_datetime_formats.end())
162
BOOST_FOREACH(TemporalFormat* it, known_datetime_formats)
188
current_format= *current;
189
if (current_format->matches(from, from_len, this))
164
if (not it->matches(from, from_len, this))
1009
978
bool Time::from_string(const char *from, size_t from_len)
1012
* Loop through the known time formats and see if
1015
bool matched= false;
1016
TemporalFormat *current_format;
1017
std::vector<TemporalFormat *>::iterator current= known_time_formats.begin();
1019
while (current != known_time_formats.end())
980
BOOST_FOREACH(TemporalFormat* it, known_time_formats)
1021
current_format= *current;
1022
if (current_format->matches(from, from_len, this))
982
if (not it->matches(from, from_len, this))
984
return is_fuzzy_valid();
1033
return is_fuzzy_valid();
1036
989
int Time::to_string(char *to, size_t to_len) const
1038
return snprintf(to, to_len,
1039
"%02" PRIu32 ":%02" PRIu32 ":%02" PRIu32,
1040
_hours, _minutes, _seconds);
991
return snprintf(to, to_len, "%02" PRIu32 ":%02" PRIu32 ":%02" PRIu32, _hours, _minutes, _seconds);
1043
994
int Date::to_string(char *to, size_t to_len) const
1045
return snprintf(to, to_len,
1046
"%04" PRIu32 "-%02" PRIu32 "-%02" PRIu32,
1047
_years, _months, _days);
996
return snprintf(to, to_len, "%04" PRIu32 "-%02" PRIu32 "-%02" PRIu32, _years, _months, _days);
1050
999
int DateTime::to_string(char *to, size_t to_len) const
1053
1002
if (_useconds == 0)
1055
1004
return snprintf(to, to_len,
1056
"%04" PRIu32 "-%02" PRIu32 "-%02" PRIu32
1057
" %02" PRIu32 ":%02" PRIu32 ":%02" PRIu32,
1058
_years, _months, _days,
1059
_hours, _minutes, _seconds);
1005
"%04" PRIu32 "-%02" PRIu32 "-%02" PRIu32 " %02" PRIu32 ":%02" PRIu32 ":%02" PRIu32,
1006
_years, _months, _days, _hours, _minutes, _seconds);
1063
1010
return snprintf(to, to_len,
1064
"%04" PRIu32 "-%02" PRIu32 "-%02" PRIu32
1065
" %02" PRIu32 ":%02" PRIu32 ":%02" PRIu32 ".%06" PRIu32,
1066
_years, _months, _days,
1067
_hours, _minutes, _seconds, _useconds);
1011
"%04" PRIu32 "-%02" PRIu32 "-%02" PRIu32 " %02" PRIu32 ":%02" PRIu32 ":%02" PRIu32 ".%06" PRIu32,
1012
_years, _months, _days, _hours, _minutes, _seconds, _useconds);
1071
1016
int MicroTimestamp::to_string(char *to, size_t to_len) const
1073
1018
return snprintf(to, to_len,
1074
"%04" PRIu32 "-%02" PRIu32 "-%02" PRIu32
1075
" %02" PRIu32 ":%02" PRIu32 ":%02" PRIu32 ".%06" PRIu32,
1076
_years, _months, _days,
1077
_hours, _minutes, _seconds, _useconds);
1019
"%04" PRIu32 "-%02" PRIu32 "-%02" PRIu32 " %02" PRIu32 ":%02" PRIu32 ":%02" PRIu32 ".%06" PRIu32,
1020
_years, _months, _days, _hours, _minutes, _seconds, _useconds);
1080
1023
void Time::to_decimal(type::Decimal *to) const
1109
1052
void Date::to_int64_t(int64_t *to) const
1111
*to= (_years * INT32_C(10000))
1112
+ (_months * INT32_C(100))
1054
*to= (_years * INT32_C(10000)) + (_months * INT32_C(100)) + _days;
1116
1057
void Date::to_int32_t(int32_t *to) const
1118
*to= (_years * INT32_C(10000))
1119
+ (_months * INT32_C(100))
1059
*to= (_years * INT32_C(10000)) + (_months * INT32_C(100)) + _days;
1123
1062
void Time::to_int32_t(int32_t *to) const
1125
*to= (_hours * INT32_C(10000))
1126
+ (_minutes * INT32_C(100))
1064
*to= (_hours * INT32_C(10000)) + (_minutes * INT32_C(100)) + _seconds;
1130
1067
// We fill the structure based on just int
1131
1068
void Time::to_uint64_t(uint64_t &to) const
1133
to= (_hours * 60 * 60)
1070
to= (_hours * 60 * 60) + (_minutes * 60) + _seconds;
1138
1073
void DateTime::to_int64_t(int64_t *to) const