~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/field/time.cc

  • Committer: patrick crews
  • Date: 2011-01-30 23:02:12 UTC
  • mto: This revision was merged to the branch mainline in revision 2131.
  • Revision ID: gleebix@gmail.com-20110130230212-nnts892jsc0oiurv
Added initial docs for dbqp.py

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
19
19
 */
20
20
 
21
 
#include <config.h>
 
21
#include "config.h"
22
22
#include <boost/lexical_cast.hpp>
23
23
#include <drizzled/field/time.h>
24
24
#include <drizzled/error.h>
30
30
 
31
31
#include <sstream>
32
32
 
33
 
#include <drizzled/temporal.h>
 
33
#include "drizzled/temporal.h"
34
34
 
35
35
namespace drizzled
36
36
{
49
49
             uint32_t,
50
50
             unsigned char *null_ptr_arg,
51
51
             unsigned char null_bit_arg,
52
 
             const char *field_name_arg) :
 
52
             const char *field_name_arg,
 
53
             const CHARSET_INFO * const cs) :
53
54
    Field_str(ptr_arg,
54
55
              DateTime::MAX_STRING_LENGTH - 1 /* no \0 */,
55
56
              null_ptr_arg,
56
57
              null_bit_arg,
57
58
              field_name_arg,
58
 
              &my_charset_bin)
 
59
              cs)
59
60
{
60
61
}
61
62
 
62
63
Time::Time(bool maybe_null_arg,
63
 
           const char *field_name_arg) :
 
64
           const char *field_name_arg,
 
65
           const CHARSET_INFO * const cs) :
64
66
  Field_str((unsigned char*) NULL,
65
67
            DateTime::MAX_STRING_LENGTH - 1 /* no \0 */,
66
68
            maybe_null_arg ? (unsigned char*) "": 0,
67
69
            0,
68
70
            field_name_arg,
69
 
            &my_charset_bin)
 
71
            cs)
70
72
{
71
73
}
72
74
 
161
163
  memcpy(ptr, &tmp, sizeof(int32_t));
162
164
}
163
165
 
164
 
void Time::unpack_time(drizzled::Time &temporal) const
 
166
void Time::unpack_time(drizzled::Time &temporal)
165
167
{
166
168
  int32_t tmp;
167
169
 
171
173
  temporal.from_int32_t(tmp);
172
174
}
173
175
 
174
 
void Time::unpack_time(int32_t &destination, const unsigned char *source) const
 
176
void Time::unpack_time(int32_t &destination, const unsigned char *source)
175
177
{
176
178
  memcpy(&destination, source, sizeof(int32_t));
177
179
  destination= htonl(destination);
178
180
}
179
181
 
180
 
double Time::val_real(void) const
 
182
double Time::val_real(void)
181
183
{
182
184
  return (double) Time::val_int();
183
185
}
184
186
 
185
 
int64_t Time::val_int(void) const
 
187
int64_t Time::val_int(void)
186
188
{
187
189
  ASSERT_COLUMN_MARKED_FOR_READ;
188
190
 
195
197
  return result;
196
198
}
197
199
 
198
 
String *Time::val_str(String *val_buffer, String *) const
 
200
String *Time::val_str(String *val_buffer, String *)
199
201
{
200
202
  char *to;
201
203
  int to_len= field_length + 1;
216
218
  return val_buffer;
217
219
}
218
220
 
219
 
bool Time::get_date(type::Time &ltime, uint32_t) const
 
221
bool Time::get_date(type::Time &ltime, uint32_t)
220
222
{
221
223
  ltime.reset();
222
224
 
234
236
  return 0;
235
237
}
236
238
 
237
 
bool Time::get_time(type::Time &ltime) const
 
239
bool Time::get_time(type::Time &ltime)
238
240
{
239
241
  return Time::get_date(ltime, 0);
240
242
}
275
277
  res.set_ascii(STRING_WITH_LEN("timestamp"));
276
278
}
277
279
 
278
 
long Time::get_timestamp(bool *null_value) const
 
280
long Time::get_timestamp(bool *null_value)
279
281
{
280
282
  if ((*null_value= is_null()))
281
283
    return 0;