~drizzle-trunk/drizzle/development

« back to all changes in this revision

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

  • Committer: Brian Aker
  • Date: 2009-10-07 16:55:53 UTC
  • mfrom: (1161.2.1 bug444827)
  • Revision ID: brian@gaz-20091007165553-9tnp7liw1k9g6gvc
Merge Padraig

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, Inc.
 
4
 *  Copyright (C) 2008 Sun Microsystems
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
17
17
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
18
 */
19
19
 
20
 
#include "config.h"
21
 
 
 
20
#include "drizzled/server_includes.h"
 
21
#include CSTDINT_H
22
22
#include "drizzled/function/time/last_day.h"
23
23
#include "drizzled/error.h"
24
24
#include "drizzled/calendar.h"
27
27
#include <sstream>
28
28
#include <string>
29
29
 
30
 
namespace drizzled
31
 
{
32
 
 
33
30
/**
34
31
 * Interpret the first argument as a DateTime string and then populate
35
32
 * our supplied temporal object with a Date representing the last day of 
36
33
 * the corresponding month and year.
37
34
 */
38
 
bool Item_func_last_day::get_temporal(Date &to)
 
35
bool Item_func_last_day::get_temporal(drizzled::Date &to)
39
36
{
40
37
  assert(fixed);
41
38
 
47
44
  }
48
45
 
49
46
  /* We use a DateTime to match as many temporal formats as possible. */
50
 
  DateTime temporal;
 
47
  drizzled::DateTime temporal;
51
48
  Item_result arg0_result_type= args[0]->result_type();
52
49
  
53
50
  switch (arg0_result_type)
78
75
          return false;
79
76
        }
80
77
 
81
 
        if (res != &tmp)
82
 
        {
83
 
          tmp.copy(*res);
84
 
        }
85
 
 
86
 
        if (! temporal.from_string(tmp.c_ptr(), tmp.length()))
 
78
        if (! temporal.from_string(res->c_ptr(), res->length()))
87
79
        {
88
80
          /* 
89
81
          * Could not interpret the function argument as a temporal value, 
90
82
          * so throw an error and return 0
91
83
          */
92
 
          my_error(ER_INVALID_DATETIME_VALUE, MYF(0), tmp.c_ptr());
 
84
          my_error(ER_INVALID_DATETIME_VALUE, MYF(0), res->c_ptr());
93
85
          return false;
94
86
        }
95
87
      }
121
113
          return false;
122
114
        }
123
115
 
124
 
        if (res != &tmp)
125
 
        {
126
 
          tmp.copy(*res);
127
 
        }
128
 
 
129
 
        my_error(ER_INVALID_DATETIME_VALUE, MYF(0), tmp.c_ptr());
 
116
        my_error(ER_INVALID_DATETIME_VALUE, MYF(0), res->c_ptr());
130
117
        return false;
131
118
      }
132
119
  }
138
125
 
139
126
  return true;
140
127
}
141
 
 
142
 
} /* namespace drizzled */