~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/field/time.cc

  • Committer: pcrews
  • Date: 2011-05-24 17:36:24 UTC
  • mfrom: (1099.4.232 drizzle)
  • Revision ID: pcrews@lucid32-20110524173624-mwr1bvq6fa1r01ao
Updated translations + 2011.05.18 tarball tag

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>
25
 
#include <drizzled/tztime.h>
26
25
#include <drizzled/table.h>
27
26
#include <drizzled/session.h>
28
 
 
29
 
#include <math.h>
30
 
 
 
27
#include <drizzled/temporal.h>
 
28
 
 
29
#include <arpa/inet.h>
 
30
#include <cmath>
31
31
#include <sstream>
32
32
 
33
 
#include "drizzled/temporal.h"
34
 
 
35
 
namespace drizzled
36
 
{
37
 
 
38
 
namespace field
39
 
{
 
33
namespace drizzled {
 
34
namespace field {
40
35
 
41
36
/**
42
37
  time_t type
49
44
             uint32_t,
50
45
             unsigned char *null_ptr_arg,
51
46
             unsigned char null_bit_arg,
52
 
             const char *field_name_arg,
53
 
             const CHARSET_INFO * const cs) :
 
47
             const char *field_name_arg) :
54
48
    Field_str(ptr_arg,
55
49
              DateTime::MAX_STRING_LENGTH - 1 /* no \0 */,
56
50
              null_ptr_arg,
57
51
              null_bit_arg,
58
52
              field_name_arg,
59
 
              cs)
 
53
              &my_charset_bin)
60
54
{
61
55
}
62
56
 
63
57
Time::Time(bool maybe_null_arg,
64
 
           const char *field_name_arg,
65
 
           const CHARSET_INFO * const cs) :
 
58
           const char *field_name_arg) :
66
59
  Field_str((unsigned char*) NULL,
67
60
            DateTime::MAX_STRING_LENGTH - 1 /* no \0 */,
68
61
            maybe_null_arg ? (unsigned char*) "": 0,
69
62
            0,
70
63
            field_name_arg,
71
 
            cs)
 
64
            &my_charset_bin)
72
65
{
73
66
}
74
67
 
75
68
int Time::store(const char *from,
76
69
                uint32_t len,
77
 
                const CHARSET_INFO * const )
 
70
                const charset_info_st * const )
78
71
{
79
72
  drizzled::Time temporal;
80
73
 
163
156
  memcpy(ptr, &tmp, sizeof(int32_t));
164
157
}
165
158
 
166
 
void Time::unpack_time(drizzled::Time &temporal)
 
159
void Time::unpack_time(drizzled::Time &temporal) const
167
160
{
168
161
  int32_t tmp;
169
162
 
173
166
  temporal.from_int32_t(tmp);
174
167
}
175
168
 
176
 
void Time::unpack_time(int32_t &destination, const unsigned char *source)
 
169
void Time::unpack_time(int32_t &destination, const unsigned char *source) const
177
170
{
178
171
  memcpy(&destination, source, sizeof(int32_t));
179
172
  destination= htonl(destination);
180
173
}
181
174
 
182
 
double Time::val_real(void)
 
175
double Time::val_real(void) const
183
176
{
184
177
  return (double) Time::val_int();
185
178
}
186
179
 
187
 
int64_t Time::val_int(void)
 
180
int64_t Time::val_int(void) const
188
181
{
189
182
  ASSERT_COLUMN_MARKED_FOR_READ;
190
183
 
197
190
  return result;
198
191
}
199
192
 
200
 
String *Time::val_str(String *val_buffer, String *)
 
193
String *Time::val_str(String *val_buffer, String *) const
201
194
{
202
195
  char *to;
203
196
  int to_len= field_length + 1;
218
211
  return val_buffer;
219
212
}
220
213
 
221
 
bool Time::get_date(type::Time &ltime, uint32_t)
 
214
bool Time::get_date(type::Time &ltime, uint32_t) const
222
215
{
223
216
  ltime.reset();
224
217
 
236
229
  return 0;
237
230
}
238
231
 
239
 
bool Time::get_time(type::Time &ltime)
 
232
bool Time::get_time(type::Time &ltime) const
240
233
{
241
234
  return Time::get_date(ltime, 0);
242
235
}
277
270
  res.set_ascii(STRING_WITH_LEN("timestamp"));
278
271
}
279
272
 
280
 
long Time::get_timestamp(bool *null_value)
 
273
long Time::get_timestamp(bool *null_value) const
281
274
{
282
275
  if ((*null_value= is_null()))
283
276
    return 0;