~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/field/date.cc

  • Committer: Brian Aker
  • Date: 2009-02-11 02:40:38 UTC
  • mfrom: (873.1.1 temporal-new)
  • Revision ID: brian@tangent.org-20090211024038-nor7dnb3zgnejq25
Merge Jay.

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
 */
20
20
 
21
21
 
22
 
#include <drizzled/server_includes.h>
23
 
#include <drizzled/field/date.h>
24
 
#include <drizzled/error.h>
25
 
#include <drizzled/table.h>
26
 
#include <drizzled/session.h>
 
22
#include "drizzled/server_includes.h"
 
23
#include "drizzled/field/date.h"
 
24
#include "drizzled/error.h"
 
25
#include "drizzled/table.h"
 
26
#include "drizzled/temporal.h"
 
27
#include "drizzled/session.h"
27
28
 
28
29
#include CMATH_H
29
30
 
59
60
                         uint32_t len,
60
61
                         const CHARSET_INFO * const )
61
62
{
 
63
#ifdef NOTDEFINED
62
64
  long tmp;
63
65
  DRIZZLE_TIME l_time;
64
66
  int error;
88
90
                         from, len, DRIZZLE_TIMESTAMP_DATE, 1);
89
91
 
90
92
  int3store(ptr, tmp);
91
 
  return error;
 
93
#endif /* NOTDEFINED */
 
94
  /* 
 
95
   * Try to create a DateTime from the supplied string.  Throw an error
 
96
   * if unable to create a valid DateTime.  A DateTime is used so that
 
97
   * automatic conversion from the higher-storage DateTime can be used
 
98
   * and matches on datetime format strings can occur.
 
99
   */
 
100
  drizzled::DateTime temporal;
 
101
  if (! temporal.from_string(from, (size_t) len))
 
102
  {
 
103
    my_error(ER_INVALID_DATETIME_VALUE, MYF(ME_FATALERROR), from);
 
104
    return 2;
 
105
  }
 
106
  /* Create the stored integer format. @TODO This should go away. Should be up to engine... */
 
107
  uint32_t int_value= (temporal.years() * 16 * 32) + (temporal.months() * 32) + temporal.days();
 
108
  int3store(ptr, int_value);
 
109
  return 0;
92
110
}
93
111
 
94
 
 
95
112
int Field_date::store(double nr)
96
113
{
97
114
  if (nr < 0.0 || nr > 99991231235959.0)