~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/field/microtime.cc

  • Committer: Andrew Hutchings
  • Date: 2011-02-01 10:23:22 UTC
  • mto: (2136.1.1 build)
  • mto: This revision was merged to the branch mainline in revision 2137.
  • Revision ID: andrew@linuxjedi.co.uk-20110201102322-oxztcyrjzg3c7yta
Fix counters cleanup

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/microtime.h>
24
24
#include <drizzled/error.h>
 
25
#include <drizzled/tztime.h>
25
26
#include <drizzled/table.h>
26
27
#include <drizzled/session.h>
27
 
#include <drizzled/session/times.h>
28
 
#include <drizzled/current_session.h>
29
 
#include <drizzled/temporal.h>
30
 
#include <cmath>
 
28
 
 
29
#include <math.h>
 
30
 
31
31
#include <sstream>
 
32
 
32
33
#include <boost/date_time/posix_time/posix_time.hpp>
33
34
 
34
 
 
35
 
namespace drizzled {
36
 
namespace field {
 
35
#include "drizzled/temporal.h"
 
36
 
 
37
namespace drizzled
 
38
{
 
39
 
 
40
namespace field
 
41
{
37
42
 
38
43
static boost::posix_time::ptime _epoch(boost::gregorian::date(1970, 1, 1));
39
44
 
61
66
 
62
67
int Microtime::store(const char *from,
63
68
                     uint32_t len,
64
 
                     const charset_info_st * const )
 
69
                     const CHARSET_INFO * const )
65
70
{
66
71
  MicroTimestamp temporal;
67
72
 
152
157
  return 0;
153
158
}
154
159
 
155
 
double Microtime::val_real(void) const
 
160
double Microtime::val_real(void)
156
161
{
157
162
  uint64_t temp;
158
163
  type::Time::usec_t micro_temp;
174
179
  return result;
175
180
}
176
181
 
177
 
type::Decimal *Microtime::val_decimal(type::Decimal *decimal_value) const
 
182
type::Decimal *Microtime::val_decimal(type::Decimal *decimal_value)
178
183
{
179
184
  type::Time ltime;
180
185
 
183
188
  return date2_class_decimal(&ltime, decimal_value);
184
189
}
185
190
 
186
 
int64_t Microtime::val_int(void) const
 
191
int64_t Microtime::val_int(void)
187
192
{
188
193
  uint64_t temp;
189
194
 
201
206
  return result;
202
207
}
203
208
 
204
 
String *Microtime::val_str(String *val_buffer, String *) const
 
209
String *Microtime::val_str(String *val_buffer, String *)
205
210
{
206
211
  uint64_t temp= 0;
207
212
  type::Time::usec_t micro_temp= 0;
218
223
  return val_buffer;
219
224
}
220
225
 
221
 
bool Microtime::get_date(type::Time &ltime, uint32_t) const
 
226
bool Microtime::get_date(type::Time &ltime, uint32_t)
222
227
{
223
228
  uint64_t temp;
224
229
  uint32_t micro_temp= 0;
233
238
  return false;
234
239
}
235
240
 
236
 
bool Microtime::get_time(type::Time &ltime) const
 
241
bool Microtime::get_time(type::Time &ltime)
237
242
{
238
243
  return Microtime::get_date(ltime, 0);
239
244
}
281
286
  Session *session= getTable() ? getTable()->in_use : current_session;
282
287
 
283
288
  type::Time::usec_t fractional_seconds= 0;
284
 
  uint64_t epoch_seconds= session->times.getCurrentTimestampEpoch(fractional_seconds);
 
289
  uint64_t epoch_seconds= session->getCurrentTimestampEpoch(fractional_seconds);
285
290
 
286
291
  set_notnull();
287
292
  pack_num(epoch_seconds);
288
293
  pack_num(fractional_seconds, ptr +8);
289
294
}
290
295
 
291
 
long Microtime::get_timestamp(bool *null_value) const
 
296
long Microtime::get_timestamp(bool *null_value)
292
297
{
293
298
  if ((*null_value= is_null()))
294
299
    return 0;