~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/function/time/unix_timestamp.cc

  • Committer: Barry.Leslie at PrimeBase
  • Date: 2011-01-22 03:22:44 UTC
  • mfrom: (2101 staging)
  • mto: (2228.1.4 build)
  • mto: This revision was merged to the branch mainline in revision 2230.
  • Revision ID: barry.leslie@primebase.com-20110122032244-ukbe3mlj7fs8xph6
Merged with lp:drizzle.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
3
 *
4
 
 *  Copyright (C) 2008 Sun Microsystems
 
4
 *  Copyright (C) 2008 Sun Microsystems, Inc.
5
5
 *
6
6
 *  This program is free software; you can redistribute it and/or modify
7
7
 *  it under the terms of the GNU General Public License as published by
20
20
#include "config.h"
21
21
 
22
22
#include <drizzled/function/time/unix_timestamp.h>
23
 
#include <drizzled/field/timestamp.h>
 
23
#include <drizzled/field/epoch.h>
24
24
#include <drizzled/session.h>
25
25
 
26
26
#include "drizzled/temporal.h"
30
30
 
31
31
int64_t Item_func_unix_timestamp::val_int()
32
32
{
33
 
  DRIZZLE_TIME ltime;
 
33
  type::Time ltime;
34
34
 
35
35
  assert(fixed == 1);
36
36
  if (arg_count == 0)
37
 
    return (int64_t) current_session->query_start();
 
37
    return (int64_t) current_session->getCurrentTimestampEpoch();
 
38
 
38
39
  if (args[0]->type() == FIELD_ITEM)
39
40
  {                                             // Optimize timestamp field
40
41
    Field *field=((Item_field*) args[0])->field;
41
42
    if (field->type() == DRIZZLE_TYPE_TIMESTAMP)
42
 
      return ((Field_timestamp*) field)->get_timestamp(&null_value);
 
43
      return ((field::Epoch::pointer) field)->get_timestamp(&null_value);
43
44
  }
44
45
 
45
46
  if (get_arg0_date(&ltime, 0))
75
76
  }
76
77
 
77
78
  time_t tmp;
78
 
  temporal.to_time_t(&tmp);
 
79
  temporal.to_time_t(tmp);
79
80
 
80
81
  return (int64_t) tmp;
81
82
}