39#include <drizzled/charset.h>
40#include <drizzled/type/decimal.h>
44#include <drizzled/time_functions.h>
47#include <drizzled/util/gmtime.h>
59extern std::vector<TemporalFormat *> known_datetime_formats;
60extern std::vector<TemporalFormat *> known_date_formats;
61extern std::vector<TemporalFormat *> known_time_formats;
79 return (uint64_t) ((_hours * INT64_C(3600))
80 + (_minutes * INT64_C(60))
94 struct tm broken_time;
96 broken_time.tm_sec= _seconds;
97 broken_time.tm_min= _minutes;
98 broken_time.tm_hour= _hours;
99 broken_time.tm_mday= _days;
100 broken_time.tm_mon= _months - 1;
101 broken_time.tm_year= _years - 1900;
103 result_time= timegm(&broken_time);
105 _epoch_seconds= result_time;
114 if (not it->matches(from, from_len,
this))
126 if (not it->matches(from, from_len,
this))
144 && _minutes == rhs._minutes
145 && _seconds == rhs._seconds
146 && _useconds == rhs._useconds
147 && _nseconds == rhs._nseconds
150bool Time::operator!=(
const Time& rhs)
152 return ! (*
this == rhs);
154bool Time::operator<(
const Time& rhs)
156 return (_cumulative_seconds_in_time() < rhs._cumulative_seconds_in_time());
158bool Time::operator<=(
const Time& rhs)
160 return (_cumulative_seconds_in_time() <= rhs._cumulative_seconds_in_time());
162bool Time::operator>(
const Time& rhs)
164 return (_cumulative_seconds_in_time() > rhs._cumulative_seconds_in_time());
166bool Time::operator>=(
const Time& rhs)
168 return (_cumulative_seconds_in_time() >= rhs._cumulative_seconds_in_time());
198 result._hours= (uint32_t) second_diff / DRIZZLE_SECONDS_IN_HOUR;
199 second_diff%= DRIZZLE_SECONDS_IN_HOUR;
200 result._minutes= (uint32_t) second_diff / DRIZZLE_SECONDS_IN_MINUTE;
201 second_diff%= DRIZZLE_SECONDS_IN_MINUTE;
202 result._seconds= (uint32_t) second_diff;
210 result._hours= (uint32_t) second_diff / DRIZZLE_SECONDS_IN_HOUR;
211 second_diff%= DRIZZLE_SECONDS_IN_HOUR;
212 result._minutes= (uint32_t) second_diff / DRIZZLE_SECONDS_IN_MINUTE;
213 second_diff%= DRIZZLE_SECONDS_IN_MINUTE;
214 result._seconds= (uint32_t) second_diff;
229 _hours= (uint32_t) second_diff / DRIZZLE_SECONDS_IN_HOUR;
230 second_diff%= DRIZZLE_SECONDS_IN_HOUR;
231 _minutes= (uint32_t) second_diff / DRIZZLE_SECONDS_IN_MINUTE;
232 second_diff%= DRIZZLE_SECONDS_IN_MINUTE;
233 _seconds= (uint32_t) second_diff;
243 _hours= (uint32_t) second_diff / DRIZZLE_SECONDS_IN_HOUR;
244 second_diff%= DRIZZLE_SECONDS_IN_HOUR;
245 _minutes= (uint32_t) second_diff / DRIZZLE_SECONDS_IN_MINUTE;
246 second_diff%= DRIZZLE_SECONDS_IN_MINUTE;
247 _seconds= (uint32_t) second_diff;
264 && _months == rhs._months
265 && _days == rhs._days
268bool Date::operator!=(
const Date& rhs)
270 return ! (*
this == rhs);
272bool Date::operator<(
const Date& rhs)
274 int64_t days_left= julian_day_number_from_gregorian_date(_years, _months, _days);
275 int64_t days_right= julian_day_number_from_gregorian_date(rhs._years, rhs._months, rhs._days);
276 return (days_left < days_right);
278bool Date::operator<=(
const Date& rhs)
282 return (days_left <= days_right);
284bool Date::operator>(
const Date& rhs)
286 return ! (*
this <= rhs);
288bool Date::operator>=(
const Date& rhs)
290 return ! (*
this < rhs);
302 && _months == rhs._months
303 && _days == rhs._days
304 && _hours == rhs._hours
305 && _minutes == rhs._minutes
306 && _seconds == rhs._seconds
307 && _useconds == rhs._useconds
308 && _nseconds == rhs._nseconds
311bool Date::operator!=(
const DateTime& rhs)
313 return ! (*
this == rhs);
315bool Date::operator<(
const DateTime& rhs)
317 int64_t days_left= julian_day_number_from_gregorian_date(_years, _months, _days);
318 int64_t days_right= julian_day_number_from_gregorian_date(rhs._years, rhs._months, rhs._days);
319 if (days_left < days_right)
321 else if (days_left > days_right)
324 return (_cumulative_seconds_in_time() < rhs._cumulative_seconds_in_time());
326bool Date::operator<=(
const DateTime& rhs)
330 if (days_left < days_right)
332 else if (days_left > days_right)
335 return (_cumulative_seconds_in_time() <= rhs._cumulative_seconds_in_time());
337bool Date::operator>(
const DateTime& rhs)
339 return ! (*
this <= rhs);
341bool Date::operator>=(
const DateTime& rhs)
343 return ! (*
this < rhs);
359 result._years= _years;
360 result._months= _months;
377 result._hours= (uint32_t) second_diff / DRIZZLE_SECONDS_IN_HOUR;
378 second_diff%= DRIZZLE_SECONDS_IN_HOUR;
379 result._minutes= (uint32_t) second_diff / DRIZZLE_SECONDS_IN_MINUTE;
380 second_diff%= DRIZZLE_SECONDS_IN_MINUTE;
381 result._seconds= (uint32_t) second_diff;
384 int64_t microsecond_diff= _useconds - rhs._useconds;
385 if (microsecond_diff < 0)
387 microsecond_diff= (-1 * microsecond_diff);
390 result._useconds= (uint32_t) microsecond_diff;
403 result._years= _years;
404 result._months= _months;
413 if (second_diff >= DRIZZLE_SECONDS_IN_DAY)
416 second_diff%= DRIZZLE_SECONDS_IN_DAY;
419 result._hours= (uint32_t) second_diff / DRIZZLE_SECONDS_IN_HOUR;
420 second_diff%= DRIZZLE_SECONDS_IN_HOUR;
421 result._minutes= (uint32_t) second_diff / DRIZZLE_SECONDS_IN_MINUTE;
422 second_diff%= DRIZZLE_SECONDS_IN_MINUTE;
423 result._seconds= (uint32_t) second_diff;
426 int64_t microsecond_diff= _useconds - rhs._useconds;
427 if (microsecond_diff < 0)
429 microsecond_diff= (-1 * microsecond_diff);
432 result._useconds= (uint32_t) microsecond_diff;
448 if (second_diff >= DRIZZLE_SECONDS_IN_DAY)
451 second_diff%= DRIZZLE_SECONDS_IN_DAY;
454 _hours= (uint32_t) second_diff / DRIZZLE_SECONDS_IN_HOUR;
455 second_diff%= DRIZZLE_SECONDS_IN_HOUR;
456 _minutes= (uint32_t) second_diff / DRIZZLE_SECONDS_IN_MINUTE;
457 second_diff%= DRIZZLE_SECONDS_IN_MINUTE;
458 _seconds= (uint32_t) second_diff;
461 int64_t microsecond_diff= _useconds - rhs._useconds;
462 if (microsecond_diff < 0)
464 microsecond_diff= (-1 * microsecond_diff);
467 _useconds= (uint32_t) microsecond_diff;
474Date& Date::operator-=(
const Time& rhs)
491 _hours= (uint32_t) second_diff / DRIZZLE_SECONDS_IN_HOUR;
492 second_diff%= DRIZZLE_SECONDS_IN_HOUR;
493 _minutes= (uint32_t) second_diff / DRIZZLE_SECONDS_IN_MINUTE;
494 second_diff%= DRIZZLE_SECONDS_IN_MINUTE;
495 _seconds= (uint32_t) second_diff;
498 int64_t microsecond_diff= _useconds - rhs._useconds;
499 if (microsecond_diff < 0)
501 microsecond_diff= (-1 * microsecond_diff);
504 _useconds= (uint32_t) microsecond_diff;
521 int64_t day_diff= day_left - day_right;
536 int64_t day_diff= day_left + day_right;
546Date& Date::operator-=(
const Date &rhs)
550 int64_t day_diff= day_left - day_right;
564 int64_t day_diff= day_left + day_right;
577 _months= rhs._months;
580 _hours= _minutes= _seconds= _useconds= _nseconds= 0;
593 int64_t day_diff= day_left - day_right;
615 result._hours= (uint32_t) second_diff / DRIZZLE_SECONDS_IN_HOUR;
616 second_diff%= DRIZZLE_SECONDS_IN_HOUR;
617 result._minutes= (uint32_t) second_diff / DRIZZLE_SECONDS_IN_MINUTE;
618 second_diff%= DRIZZLE_SECONDS_IN_MINUTE;
619 result._seconds= (uint32_t) second_diff;
622 int64_t microsecond_diff= _useconds - rhs._useconds;
623 if (microsecond_diff < 0)
625 microsecond_diff= (-1 * microsecond_diff);
628 result._useconds= (uint32_t) microsecond_diff;
640 int64_t day_diff= day_left + day_right;
655 if (second_diff >= DRIZZLE_SECONDS_IN_DAY)
658 second_diff%= DRIZZLE_SECONDS_IN_DAY;
661 result._hours= (uint32_t) second_diff / DRIZZLE_SECONDS_IN_HOUR;
662 second_diff%= DRIZZLE_SECONDS_IN_HOUR;
663 result._minutes= (uint32_t) second_diff / DRIZZLE_SECONDS_IN_MINUTE;
664 second_diff%= DRIZZLE_SECONDS_IN_MINUTE;
665 result._seconds= (uint32_t) second_diff;
668 int64_t microsecond_diff= _useconds - rhs._useconds;
669 if (microsecond_diff < 0)
671 microsecond_diff= (-1 * microsecond_diff);
674 result._useconds= (uint32_t) microsecond_diff;
684 int64_t day_diff= day_left - day_right;
705 _hours= (uint32_t) second_diff / DRIZZLE_SECONDS_IN_HOUR;
706 second_diff%= DRIZZLE_SECONDS_IN_HOUR;
707 _minutes= (uint32_t) second_diff / DRIZZLE_SECONDS_IN_MINUTE;
708 second_diff%= DRIZZLE_SECONDS_IN_MINUTE;
709 _seconds= (uint32_t) second_diff;
712 int64_t microsecond_diff= _useconds - rhs._useconds;
713 if (microsecond_diff < 0)
715 microsecond_diff= (-1 * microsecond_diff);
718 _useconds= (uint32_t) microsecond_diff;
730 int64_t day_diff= day_left + day_right;
744 if (second_diff >= DRIZZLE_SECONDS_IN_DAY)
747 second_diff%= DRIZZLE_SECONDS_IN_DAY;
750 _hours= (uint32_t) second_diff / DRIZZLE_SECONDS_IN_HOUR;
751 second_diff%= DRIZZLE_SECONDS_IN_HOUR;
752 _minutes= (uint32_t) second_diff / DRIZZLE_SECONDS_IN_MINUTE;
753 second_diff%= DRIZZLE_SECONDS_IN_MINUTE;
754 _seconds= (uint32_t) second_diff;
757 int64_t microsecond_diff= _useconds - rhs._useconds;
758 if (microsecond_diff < 0)
760 microsecond_diff= (-1 * microsecond_diff);
763 _useconds= (uint32_t) microsecond_diff;
773 return (_years == rhs._years && _months == rhs._months && _days == rhs._days);
775bool Date::operator!=(
const Timestamp& rhs)
777 return ! (*
this == rhs);
779bool Date::operator<(
const Timestamp& rhs)
781 if (_years < rhs._years)
783 if (_years > rhs._years)
786 if (_months < rhs._months)
788 if (_months > rhs._months)
791 return _days < rhs._days;
793bool Date::operator<=(
const Timestamp& rhs)
795 return (*
this < rhs || *
this == rhs);
797bool Date::operator>(
const Timestamp& rhs)
799 return ! (*
this <= rhs);
801bool Date::operator>=(
const Timestamp& rhs)
803 return ! (*
this < rhs);
810 return (_years == rhs._years && _months == rhs._months && _days == rhs._days);
812bool Timestamp::operator!=(
const Date& rhs)
814 return ! (*
this == rhs);
816bool Timestamp::operator<(
const Date& rhs)
818 if (_years < rhs._years)
820 if (_years > rhs._years)
823 if (_months < rhs._months)
825 if (_months > rhs._months)
828 return _days < rhs._days;
830bool Timestamp::operator<=(
const Date& rhs)
832 return (*
this < rhs || *
this == rhs);
834bool Timestamp::operator>(
const Date& rhs)
836 return ! (*
this <= rhs);
838bool Timestamp::operator>=(
const Date& rhs)
840 return ! (*
this < rhs);
847 return (_years == rhs._years && _months == rhs._months && _days == rhs._days
848 && _hours == rhs._hours && _minutes == rhs._minutes && _seconds == rhs._seconds);
850bool Timestamp::operator!=(
const DateTime& rhs)
852 return ! (*
this == rhs);
854bool Timestamp::operator<(
const DateTime& rhs)
856 if (_years < rhs._years)
858 if (_years > rhs._years)
861 if (_months < rhs._months)
863 if (_months > rhs._months)
866 if (_days < rhs._days)
868 if (_days > rhs._days)
871 if (_hours < rhs._hours)
873 if (_hours > rhs._hours)
876 if (_minutes < rhs._minutes)
878 if (_minutes > rhs._minutes)
881 return _seconds < rhs._seconds;
883bool Timestamp::operator<=(
const DateTime& rhs)
885 return (*
this < rhs || *
this == rhs);
887bool Timestamp::operator>(
const DateTime& rhs)
889 return ! (*
this <= rhs);
891bool Timestamp::operator>=(
const DateTime& rhs)
893 return ! (*
this < rhs);
900 return (_epoch_seconds == rhs._epoch_seconds);
902bool Timestamp::operator!=(
const Timestamp& rhs)
904 return ! (*
this == rhs);
906bool Timestamp::operator<(
const Timestamp& rhs)
908 return (_epoch_seconds < rhs._epoch_seconds);
910bool Timestamp::operator<=(
const Timestamp& rhs)
912 return (_epoch_seconds <= rhs._epoch_seconds);
914bool Timestamp::operator>(
const Timestamp& rhs)
916 return ! (*
this <= rhs);
918bool Timestamp::operator>=(
const Timestamp& rhs)
920 return ! (*
this < rhs);
930std::ostream& operator<<(std::ostream& os,
const Timestamp& subject)
932 return os << subject.
years() <<
'-'
933 << std::setw(2) << std::setfill(
'0') << subject.
months() <<
'-'
934 << std::setw(2) << std::setfill(
'0') << subject.
days() <<
' '
935 << std::setw(2) << std::setfill(
'0') << subject.
hours() <<
':'
936 << std::setw(2) << std::setfill(
'0') << subject.
minutes() <<
':'
937 << std::setw(2) << std::setfill(
'0') << subject.
seconds();
944 if (not it->matches(from, from_len,
this))
946 return is_fuzzy_valid();
953 return snprintf(to, to_len,
"%02" PRIu32
":%02" PRIu32
":%02" PRIu32, _hours, _minutes, _seconds);
958 return snprintf(to, to_len,
"%04" PRIu32
"-%02" PRIu32
"-%02" PRIu32, _years, _months, _days);
966 return snprintf(to, to_len,
967 "%04" PRIu32
"-%02" PRIu32
"-%02" PRIu32
" %02" PRIu32
":%02" PRIu32
":%02" PRIu32,
968 _years, _months, _days, _hours, _minutes, _seconds);
972 return snprintf(to, to_len,
973 "%04" PRIu32
"-%02" PRIu32
"-%02" PRIu32
" %02" PRIu32
":%02" PRIu32
":%02" PRIu32
".%06" PRIu32,
974 _years, _months, _days, _hours, _minutes, _seconds, _useconds);
980 return snprintf(to, to_len,
981 "%04" PRIu32
"-%02" PRIu32
"-%02" PRIu32
" %02" PRIu32
":%02" PRIu32
":%02" PRIu32
".%06" PRIu32,
982 _years, _months, _days, _hours, _minutes, _seconds, _useconds);
987 int64_t time_portion= (((_hours * 100L) + _minutes) * 100L) + _seconds;
988 (void) int2_class_decimal(E_DEC_FATAL_ERROR, time_portion,
false, to);
991 to->buf[(to->intg-1) / 9 + 1]= _useconds * 1000;
998 int64_t date_portion= (((_years * 100L) + _months) * 100L) + _days;
999 (void) int2_class_decimal(E_DEC_FATAL_ERROR, date_portion,
false, to);
1004 int64_t date_portion= (((_years * 100L) + _months) * 100L) + _days;
1005 int64_t time_portion= (((((date_portion * 100L) + _hours) * 100L) + _minutes) * 100L) + _seconds;
1006 (void) int2_class_decimal(E_DEC_FATAL_ERROR, time_portion,
false, to);
1009 to->buf[(to->intg-1) / 9 + 1]= _useconds * 1000;
1016 *to= (_years * INT32_C(10000)) + (_months * INT32_C(100)) + _days;
1021 *to= (_years * INT32_C(10000)) + (_months * INT32_C(100)) + _days;
1026 *to= (_hours * INT32_C(10000)) + (_minutes * INT32_C(100)) + _seconds;
1032 to= (_hours * 60 * 60) + (_minutes * 60) + _seconds;
1038 (_years * INT64_C(10000))
1039 + (_months * INT64_C(100))
1041 ) * INT64_C(1000000))
1043 (_hours * INT64_C(10000))
1044 + (_minutes * INT64_C(100) )
1055 to->tm_mon= _months - 1;
1056 to->tm_year= _years - 1900;
1061 to->tm_sec= _seconds;
1062 to->tm_min= _minutes;
1063 to->tm_hour= _hours;
1065 to->tm_mon= _months - 1;
1066 to->tm_year= _years - 1900;
1085 return ((
DateTime *)
this)->from_int64_t((int64_t) from);
1094 uint32_t copy_from= (uint32_t) from;
1095 _hours= copy_from / INT32_C(10000);
1096 _minutes= (copy_from % INT32_C(10000)) / INT32_C(100);
1097 _seconds= copy_from % INT32_C(100);
1108 int64_t copy_from= from;
1112 if (copy_from == 0LL)
1115 if (convert && copy_from < 10000101000000LL)
1117 if (copy_from < 101)
1119 else if (copy_from <= (DRIZZLE_YY_PART_YEAR-1)*10000L+1231L)
1120 copy_from= (copy_from+20000000L)*1000000L;
1121 else if (copy_from < (DRIZZLE_YY_PART_YEAR)*10000L+101L)
1123 else if (copy_from <= 991231L)
1124 copy_from= (copy_from+19000000L)*1000000L;
1125 else if (copy_from < 10000101L)
1127 else if (copy_from <= 99991231L)
1128 copy_from= copy_from*1000000L;
1129 else if (copy_from < 101000000L)
1131 else if (copy_from <= (DRIZZLE_YY_PART_YEAR-1) * 10000000000LL + 1231235959LL)
1132 copy_from= copy_from + 20000000000000LL;
1133 else if (copy_from < DRIZZLE_YY_PART_YEAR * 10000000000LL + 101000000LL)
1135 else if (copy_from <= 991231235959LL)
1136 copy_from= copy_from + 19000000000000LL;
1139 part1= (int64_t) (copy_from / 1000000LL);
1140 part2= (int64_t) (copy_from - (int64_t) part1 * 1000000LL);
1141 _years= (uint32_t) (part1/10000L);
1144 _months= (uint32_t) part1 / 100;
1145 _days= (uint32_t) part1 % 100;
1146 _hours= (uint32_t) (part2/10000L);
1149 _minutes= (uint32_t) part2 / 100;
1150 _seconds= (uint32_t) part2 % 100;
1156bool Date::in_unix_epoch()
const
1168 _years= 1900 + from->tm_year;
1169 _months= 1 + from->tm_mon;
1170 _days= from->tm_mday;
1171 _hours= from->tm_hour;
1172 _minutes= from->tm_min;
1173 _seconds= from->tm_sec;
1188 struct tm broken_time;
1191 result= util::gmtime(from, &broken_time);
1197 _hours= broken_time.tm_hour;
1198 _minutes= broken_time.tm_min;
1199 _seconds= broken_time.tm_sec;
1212 struct tm broken_time;
1215 result= util::gmtime(from, &broken_time);
1218 _years= 1900 + broken_time.tm_year;
1219 _months= 1 + broken_time.tm_mon;
1220 _days= broken_time.tm_mday;
1234bool DateTime::from_timeval(
struct timeval &timeval_arg)
1236 struct tm broken_time;
1239 result= util::gmtime(timeval_arg.tv_sec, &broken_time);
1242 _years= 1900 + broken_time.tm_year;
1243 _months= 1 + broken_time.tm_mon;
1244 _days= broken_time.tm_mday;
1245 _hours= broken_time.tm_hour;
1246 _minutes= broken_time.tm_min;
1247 _seconds= broken_time.tm_sec;
1248 _epoch_seconds= timeval_arg.tv_sec;
1250 _useconds= timeval_arg.tv_usec;
1262 struct tm broken_time;
1265 result= util::gmtime(from, &broken_time);
1268 _years= 1900 + broken_time.tm_year;
1269 _months= 1 + broken_time.tm_mon;
1270 _days= broken_time.tm_mday;
1271 _hours= broken_time.tm_hour;
1272 _minutes= broken_time.tm_min;
1273 _seconds= broken_time.tm_sec;
1274 _epoch_seconds= from;
1288 if (in_unix_epoch())
1305 to.tv_sec= _epoch_seconds;
1306 to.tv_usec= _useconds;
1311 to->tv_sec= _epoch_seconds;
1312 to->tv_nsec= _nseconds;
1317 return (_years >= DRIZZLE_MIN_YEARS_SQL && _years <= DRIZZLE_MAX_YEARS_SQL)
1318 && (_months >= 1 && _months <= DRIZZLE_MAX_MONTHS)
1324 return (_years == 0)
1327 && (_hours <= DRIZZLE_MAX_HOURS)
1328 && (_minutes <= DRIZZLE_MAX_MINUTES)
1329 && (_seconds <= DRIZZLE_MAX_SECONDS);
1332bool Time::is_fuzzy_valid()
const
1337 return (_years >= DRIZZLE_MIN_YEARS_SQL && _years <= DRIZZLE_MAX_YEARS_SQL)
1338 && (_months >= 1 && _months <= DRIZZLE_MAX_MONTHS)
1340 && (_hours <= DRIZZLE_MAX_HOURS)
1341 && (_minutes <= DRIZZLE_MAX_MINUTES)
1342 && (_seconds <= DRIZZLE_MAX_SECONDS);
1347 return (_years >= DRIZZLE_MIN_YEARS_SQL && _years <= DRIZZLE_MAX_YEARS_SQL)
1348 && (_months >= 1 && _months <= DRIZZLE_MAX_MONTHS)
1350 && (_hours <= DRIZZLE_MAX_HOURS)
1351 && (_minutes <= DRIZZLE_MAX_MINUTES)
1352 && (_seconds <= DRIZZLE_MAX_SECONDS_WITH_LEAP);
1359 && (_seconds <= DRIZZLE_MAX_SECONDS);
1365 && (_useconds <= UINT32_C(999999));
1371 && (_useconds <= UINT32_C(999999))
1372 && (_nseconds <= UINT32_C(999999999));
void to_tm(struct tm *to) const
void to_decimal(type::Decimal *to) const
virtual int to_string(char *to, size_t to_len) const
bool in_unix_epoch() const
bool from_string(const char *from, size_t from_len)
bool from_int64_t(const int64_t from, bool convert)
void to_int64_t(int64_t *to) const
virtual bool is_valid() const
bool from_time_t(const time_t from)
virtual bool from_time_t(const time_t from)
bool from_julian_day_number(const int64_t from)
virtual void to_decimal(type::Decimal *to) const
virtual int to_string(char *to, size_t to_len) const
virtual void to_time_t(time_t &to) const
virtual void to_int32_t(int32_t *to) const
virtual void to_int64_t(int64_t *to) const
const Date operator-(const Date &rhs)
virtual bool from_string(const char *from, size_t from_len)
void to_julian_day_number(int64_t *to) const
virtual bool from_int32_t(const int32_t from)
const Date operator+(const Date &rhs)
Date & operator+=(const Date &rhs)
virtual bool operator==(const Date &rhs)
Date & operator=(const DateTime &rhs)
virtual void to_tm(struct tm *to) const
virtual bool from_tm(const struct tm *from)
virtual bool is_valid() const
int to_string(char *to, size_t to_len) const
void to_timeval(struct timeval &to) const
void to_timespec(struct timespec *to) const
friend class TemporalFormat
uint64_t _cumulative_seconds_in_time() const
bool from_time_t(const time_t from)
void to_uint64_t(uint64_t &to) const
bool operator==(const Time &rhs)
Time & operator+=(const Time &rhs)
const Time operator-(const Time &rhs)
void to_int32_t(int32_t *to) const
void to_decimal(type::Decimal *to) const
const Time operator+(const Time &rhs)
Time & operator-=(const Time &rhs)
int to_string(char *to, size_t to_len) const
bool from_int32_t(const int32_t from)
bool from_string(const char *from, size_t from_len)
bool operator==(const Date &rhs)
virtual bool is_valid() const
void to_time_t(time_t &to) const
TODO: Rename this file - func.h is stupid.
void gregorian_date_from_julian_day_number(int64_t julian_day, uint32_t *year_out, uint32_t *month_out, uint32_t *day_out)
int64_t julian_day_number_from_gregorian_date(uint32_t year, uint32_t month, uint32_t day)
uint32_t days_in_gregorian_year_month(uint32_t year, uint32_t month)
bool in_unix_epoch_range(uint32_t year, uint32_t month, uint32_t day, uint32_t hour, uint32_t minute, uint32_t second)