44 #define DRIZZLE_MAX_SECONDS 59
45 #define DRIZZLE_MAX_SECONDS_WITH_LEAP 61
46 #define DRIZZLE_MAX_MINUTES 59
47 #define DRIZZLE_MAX_HOURS 23
48 #define DRIZZLE_MAX_DAYS 31
49 #define DRIZZLE_MAX_MONTHS 12
50 #define DRIZZLE_MAX_YEARS_SQL 9999
51 #define DRIZZLE_MAX_YEARS_EPOCH 2038
52 #define DRIZZLE_MIN_SECONDS 0
53 #define DRIZZLE_MIN_MINUTES 0
54 #define DRIZZLE_MIN_HOURS 0
55 #define DRIZZLE_MIN_DAYS 1
56 #define DRIZZLE_MIN_MONTHS 1
57 #define DRIZZLE_MIN_YEARS_SQL 1
58 #define DRIZZLE_MIN_YEARS_EPOCH 1970
60 #define DRIZZLE_SECONDS_IN_MINUTE 60
61 #define DRIZZLE_SECONDS_IN_HOUR (60*60)
62 #define DRIZZLE_SECONDS_IN_DAY (60*60*24)
63 #define DRIZZLE_NANOSECONDS_IN_MICROSECOND 1000
65 #define DRIZZLE_MAX_LENGTH_DATETIME_AS_STRING 40
67 #define DRIZZLE_YY_PART_YEAR 70
70 #include <drizzled/common_fwd.h>
89 time_t _epoch_seconds;
95 uint64_t _cumulative_seconds_in_time()
const;
99 _years= _months= _days= _hours= _minutes=
100 _seconds= _epoch_seconds= _useconds= _nseconds= 0;
112 inline uint32_t
nseconds()
const {
return _nseconds;}
116 inline uint32_t
useconds()
const {
return _useconds;}
121 void set_epoch_seconds();
124 {_epoch_seconds= epoch_second;}
128 inline void set_seconds(
const uint32_t second) {_seconds= second;}
130 inline uint32_t
seconds()
const {
return _seconds;}
132 inline void set_minutes(
const uint32_t minute) {_minutes= minute;}
134 inline uint32_t
minutes()
const {
return _minutes;}
136 inline void set_hours(
const uint32_t hour) {_hours= hour;}
138 inline uint32_t
hours()
const {
return _hours;}
140 inline void set_days(
const uint32_t day) {_days= day;}
142 inline uint32_t
days()
const {
return _days;}
144 inline void set_months(
const uint32_t month) {_months= month;}
146 inline uint32_t
months()
const {
return _months;}
148 inline void set_years(
const uint32_t year) {_years= year;}
150 inline uint32_t
years()
const {
return _years;}
156 virtual bool is_valid_date()
const= 0;
158 virtual bool is_valid_datetime()
const= 0;
160 virtual bool is_valid_time()
const= 0;
162 virtual bool is_valid_timestamp()
const= 0;
169 virtual bool is_valid()
const= 0;
201 virtual bool operator==(
const Date &rhs);
202 virtual bool operator!=(
const Date &rhs);
203 virtual bool operator>(
const Date &rhs);
204 virtual bool operator>=(
const Date &rhs);
205 virtual bool operator<(
const Date &rhs);
206 virtual bool operator<=(
const Date &rhs);
214 virtual bool operator==(
const DateTime &rhs);
215 virtual bool operator!=(
const DateTime &rhs);
216 virtual bool operator>(
const DateTime &rhs);
217 virtual bool operator>=(
const DateTime &rhs);
218 virtual bool operator<(
const DateTime &rhs);
219 virtual bool operator<=(
const DateTime &rhs);
227 virtual bool operator==(
const Timestamp &rhs);
228 virtual bool operator!=(
const Timestamp &rhs);
229 virtual bool operator>(
const Timestamp &rhs);
230 virtual bool operator>=(
const Timestamp &rhs);
231 virtual bool operator<(
const Timestamp &rhs);
232 virtual bool operator<=(
const Timestamp &rhs);
241 const Date operator-(
const Date &rhs);
242 const Date operator+(
const Date &rhs);
252 const Date operator-(
const Time &rhs);
253 const Date operator+(
const Time &rhs);
285 return is_valid() && in_unix_epoch();
289 virtual bool is_valid()
const;
291 virtual bool in_unix_epoch()
const;
304 virtual int to_string(
char *to,
size_t to_len)
const;
310 static const int MAX_STRING_LENGTH= 11;
322 virtual bool from_string(
const char *from,
size_t from_len);
331 virtual void to_int64_t(int64_t *to)
const;
340 virtual void to_int32_t(int32_t *to)
const;
351 virtual bool from_int32_t(
const int32_t from);
366 void to_julian_day_number(int64_t *to)
const;
377 bool from_julian_day_number(
const int64_t from);
386 virtual void to_tm(
struct tm *to)
const;
398 virtual bool from_tm(
const struct tm *from);
406 virtual void to_time_t(time_t &to)
const;
417 virtual bool from_time_t(
const time_t from);
443 static const uint32_t MAX_CUMULATIVE_SECONDS= 86400L;
451 bool operator==(
const Time &rhs);
452 bool operator!=(
const Time &rhs);
453 bool operator>(
const Time &rhs);
454 bool operator>=(
const Time &rhs);
455 bool operator<(
const Time &rhs);
456 bool operator<=(
const Time &rhs);
463 const Time operator-(
const Time &rhs);
464 const Time operator+(
const Time &rhs);
474 bool is_valid()
const;
475 bool is_fuzzy_valid()
const;
488 int to_string(
char *to,
size_t to_len)
const;
494 static const int MAX_STRING_LENGTH= 9;
507 bool from_string(
const char *from,
size_t from_len);
516 void to_int32_t(int32_t *to)
const;
525 void to_uint64_t(uint64_t &to)
const;
536 bool from_int32_t(
const int32_t from);
552 bool from_time_t(
const time_t from);
580 bool in_unix_epoch()
const;
582 virtual bool is_valid()
const;
602 virtual int to_string(
char *to,
size_t to_len)
const;
608 static const int MAX_STRING_LENGTH= 27;
620 bool from_string(
const char *from,
size_t from_len);
629 void to_int64_t(int64_t *to)
const;
640 bool from_time_t(
const time_t from);
641 bool from_timeval(
struct timeval &_timeval);
654 bool from_int64_t(
const int64_t from,
bool convert);
656 bool from_int64_t(
const int64_t from) {
657 return from_int64_t(from,
true);
667 void to_tm(
struct tm *to)
const;
694 bool operator==(
const Date &rhs);
695 bool operator!=(
const Date &rhs);
696 bool operator>(
const Date &rhs);
697 bool operator>=(
const Date &rhs);
698 bool operator<(
const Date &rhs);
699 bool operator<=(
const Date &rhs);
707 bool operator==(
const DateTime &rhs);
708 bool operator!=(
const DateTime &rhs);
709 bool operator>(
const DateTime &rhs);
710 bool operator>=(
const DateTime &rhs);
711 bool operator<(
const DateTime &rhs);
712 bool operator<=(
const DateTime &rhs);
729 virtual bool is_valid()
const;
737 void to_time_t(time_t &to)
const;
743 std::ostream& operator<<(std::ostream& os,
const Timestamp& subject);
754 bool is_valid()
const;
767 int to_string(
char *to,
size_t to_len)
const;
773 static const int MAX_STRING_LENGTH= 27;
785 void to_timeval(
struct timeval &to)
const;
797 bool is_valid()
const;
809 void to_timespec(
struct timespec *to)
const;