~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/type/time.h

  • Committer: Brian Aker
  • Date: 2011-01-13 00:08:59 UTC
  • mto: (2082.4.1 timestamp)
  • mto: This revision was merged to the branch mainline in revision 2098.
  • Revision ID: brian@tangent.org-20110113000859-8dw4ybnp8id56u50
Fix issue with return value from unix_timestamp(). Also clean up error
messages, and remove limit on value for timestamp.

Show diffs side-by-side

added added

removed removed

Lines of Context:
41
41
extern unsigned char days_in_month[];
42
42
 
43
43
/* Time handling defaults */
44
 
#define TIMESTAMP_MAX_YEAR 2038
45
44
#define TIMESTAMP_MIN_YEAR (1900 + YY_PART_YEAR - 1)
46
45
#define TIMESTAMP_MAX_VALUE INT32_MAX
47
46
#define TIMESTAMP_MIN_VALUE 1
94
93
class Time
95
94
{
96
95
public:
 
96
  typedef uint32_t usec_t;
 
97
 
97
98
  unsigned int year, month, day, hour, minute, second;
98
 
  unsigned int second_part;
99
 
  bool       neg;
 
99
  usec_t second_part;
 
100
  bool neg;
100
101
  enum enum_drizzle_timestamp_type time_type;
101
102
 
102
103
  void reset()
107
108
  }
108
109
 
109
110
  void convert(drizzled::String &str, const enum_drizzle_timestamp_type arg= DRIZZLE_TIMESTAMP_DATETIME);
 
111
 
 
112
  static const uint32_t FRACTIONAL_DIGITS= 1000000;
110
113
};
111
114
 
112
115
}
122
125
uint64_t TIME_to_uint64_t(const type::Time *);
123
126
 
124
127
 
125
 
bool str_to_time(const char *str,uint32_t length, type::Time *l_time,
126
 
                 int *warning);
 
128
bool str_to_time(const char *str,uint32_t length, type::Time *l_time, int *warning);
127
129
 
128
130
long calc_daynr(uint32_t year,uint32_t month,uint32_t day);
129
131
uint32_t calc_days_in_year(uint32_t year);
147
149
 
148
150
static inline bool validate_timestamp_range(const type::Time *t)
149
151
{
150
 
  if ((t->year > TIMESTAMP_MAX_YEAR || t->year < TIMESTAMP_MIN_YEAR) ||
151
 
      (t->year == TIMESTAMP_MAX_YEAR && (t->month > 1 || t->day > 19)) ||
152
 
      (t->year == TIMESTAMP_MIN_YEAR && (t->month < 12 || t->day < 31)))
 
152
  if ((t->year < TIMESTAMP_MIN_YEAR) or (t->year == TIMESTAMP_MIN_YEAR && (t->month < 12 || t->day < 31)))
 
153
  {
153
154
    return false;
 
155
  }
154
156
 
155
157
  return true;
156
158
}