~drizzle-trunk/drizzle/development

« back to all changes in this revision

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

  • Committer: Brian Aker
  • Date: 2009-01-07 09:27:07 UTC
  • Revision ID: brian@tangent.org-20090107092707-bn67qpdllfcyh3j9
Removing dead field translator code.

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
18
 */
19
19
 
20
 
#include "config.h"
21
 
#include <boost/lexical_cast.hpp>
22
 
#include "drizzled/function/time/from_days.h"
23
 
#include "drizzled/error.h"
24
 
#include "drizzled/temporal.h"
25
 
 
26
 
#include <sstream>
27
 
#include <string>
28
 
 
29
 
namespace drizzled
30
 
{
31
 
 
32
 
/**
33
 
 * Interpret the first argument as a Julian Day Number and fill
34
 
 * our supplied temporal object.
35
 
 */
36
 
bool Item_func_from_days::get_temporal(Date &to)
37
 
{
38
 
  assert(fixed);
39
 
 
40
 
  /* 
41
 
   * We MUST call val_int() before checking null_value because, stupidly, 
42
 
   * a subselect does not evaluate it's scalar items as null until val_xxx()
43
 
   * has been called. :(
44
 
   */
45
 
  int64_t int_value= args[0]->val_int();
46
 
 
47
 
  /* We return NULL from FROM_DAYS() only when supplied a NULL argument */
48
 
  if (args[0]->null_value)
49
 
  {
50
 
    null_value= true;
51
 
    return false;
52
 
  }
53
 
 
54
 
  /* OK, now try to convert from our integer */
55
 
  if (! to.from_julian_day_number(int_value))
56
 
  {
57
 
    /* Bad input, throw an error */
58
 
    std::string tmp(boost::lexical_cast<std::string>(int_value));
59
 
 
60
 
    my_error(ER_ARGUMENT_OUT_OF_RANGE, MYF(ME_FATALERROR), tmp.c_str(), func_name());
61
 
    return false;
62
 
  }
63
 
  return true;
 
20
#include <drizzled/server_includes.h>
 
21
#include CSTDINT_H
 
22
#include <drizzled/function/time/from_days.h>
 
23
 
 
24
bool Item_func_from_days::get_date(DRIZZLE_TIME *ltime, uint32_t fuzzy_date __attribute__((unused)))
 
25
{
 
26
  int64_t value=args[0]->val_int();
 
27
  if ((null_value=args[0]->null_value))
 
28
    return 1;
 
29
  memset(ltime, 0, sizeof(DRIZZLE_TIME));
 
30
  get_date_from_daynr((long) value, &ltime->year, &ltime->month, &ltime->day);
 
31
  ltime->time_type= DRIZZLE_TIMESTAMP_DATE;
 
32
  return 0;
64
33
}
65
34
 
66
 
} /* namespace drizzled */