~drizzle-trunk/drizzle/development

« back to all changes in this revision

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

  • Committer: Brian Aker
  • Date: 2010-01-22 00:53:13 UTC
  • Revision ID: brian@gaz-20100122005313-jmizcbcdi1lt4tcx
Revert db patch.

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
 
 
22
 
#include <drizzled/function/time/to_days.h>
23
 
#include <drizzled/error.h>
24
 
#include <drizzled/temporal.h>
25
 
 
26
 
namespace drizzled
27
 
{
 
20
#include "config.h"
 
21
#include CSTDINT_H
 
22
#include "drizzled/function/time/to_days.h"
 
23
#include "drizzled/error.h"
 
24
#include "drizzled/temporal.h"
28
25
 
29
26
/* 
30
27
 * We intepret the first argument as a DateTime and then convert
51
48
   * error and return 0, setting the null_value flag to true.
52
49
   */
53
50
  /* Grab the first argument as a DateTime object */
54
 
  DateTime temporal;
 
51
  drizzled::DateTime temporal;
55
52
  Item_result arg0_result_type= args[0]->result_type();
56
53
  
57
54
  switch (arg0_result_type)
82
79
          return false;
83
80
        }
84
81
 
85
 
        if (res != &tmp)
86
 
        {
87
 
          tmp.copy(*res);
88
 
        }
89
 
 
90
 
        if (! temporal.from_string(tmp.c_ptr(), tmp.length()))
 
82
        if (! temporal.from_string(res->c_ptr(), res->length()))
91
83
        {
92
84
          /* 
93
85
          * Could not interpret the function argument as a temporal value, 
94
86
          * so throw an error and return 0
95
87
          */
96
 
          my_error(ER_INVALID_DATETIME_VALUE, MYF(0), tmp.c_ptr());
 
88
          my_error(ER_INVALID_DATETIME_VALUE, MYF(0), res->c_ptr());
97
89
          return 0;
98
90
        }
99
91
      }
125
117
          return false;
126
118
        }
127
119
 
128
 
        if (res != &tmp)
129
 
        {
130
 
          tmp.copy(*res);
131
 
        }
132
 
 
133
 
        my_error(ER_INVALID_DATETIME_VALUE, MYF(0), tmp.c_ptr());
 
120
        my_error(ER_INVALID_DATETIME_VALUE, MYF(0), res->c_ptr());
134
121
        return 0;
135
122
      }
136
123
  }
153
140
   * the appropriate end-point integer.
154
141
   */
155
142
  /* Grab the first argument as a DateTime object */
156
 
  DateTime temporal;
 
143
  drizzled::DateTime temporal;
157
144
  Item_result arg0_result_type= args[0]->result_type();
158
145
  
159
146
  switch (arg0_result_type)
184
171
          return 0;
185
172
        }
186
173
 
187
 
        if (res != &tmp)
188
 
        {
189
 
          tmp.copy(*res);
190
 
        }
191
 
 
192
 
        if (! temporal.from_string(tmp.c_ptr(), tmp.length()))
 
174
        if (! temporal.from_string(res->c_ptr(), res->length()))
193
175
        {
194
176
          /* 
195
177
          * Could not interpret the function argument as a temporal value, 
196
178
          * so throw an error and return 0
197
179
          */
198
 
          my_error(ER_INVALID_DATETIME_VALUE, MYF(0), tmp.c_ptr());
 
180
          my_error(ER_INVALID_DATETIME_VALUE, MYF(0), res->c_ptr());
199
181
          return 0;
200
182
        }
201
183
      }
227
209
          return 0;
228
210
        }
229
211
 
230
 
        if (res != &tmp)
231
 
        {
232
 
          tmp.copy(*res);
233
 
        }
234
 
 
235
 
        my_error(ER_INVALID_DATETIME_VALUE, MYF(0), tmp.c_ptr());
 
212
        my_error(ER_INVALID_DATETIME_VALUE, MYF(0), res->c_ptr());
236
213
        return 0;
237
214
      }
238
215
  }
276
253
    *incl_endp= true;
277
254
  return julian_day_number;
278
255
}
279
 
 
280
 
} /* namespace drizzled */