~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/temporal_interval.cc

Merge in Stewart's FK work

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/internal/m_string.h>
23
 
#include <drizzled/error.h>
24
 
#include <drizzled/session.h>
25
 
#include <drizzled/current_session.h>
26
 
#include <drizzled/function/time/date.h>
27
 
#include <drizzled/temporal_interval.h>
28
 
#include <drizzled/time_functions.h>
 
20
#include "config.h"
 
21
#include "drizzled/internal/m_string.h"
 
22
#include "drizzled/error.h"
 
23
#include "drizzled/session.h"
 
24
#include "config.h"
 
25
#include "drizzled/function/time/date.h"
 
26
#include "drizzled/temporal_interval.h"
 
27
#include "drizzled/time_functions.h"
29
28
 
30
29
namespace drizzled
31
30
{
187
186
  return false;
188
187
}
189
188
 
190
 
bool TemporalInterval::addDate(type::Time *ltime, interval_type int_type)
 
189
bool TemporalInterval::addDate(DRIZZLE_TIME *ltime, interval_type int_type)
191
190
{
192
191
  long period, sign;
193
192
 
212
211
  case INTERVAL_DAY_MINUTE:
213
212
  case INTERVAL_DAY_HOUR:
214
213
    int64_t sec, days, daynr, microseconds, extra_sec;
215
 
    ltime->time_type= type::DRIZZLE_TIMESTAMP_DATETIME; // Return full date
 
214
    ltime->time_type= DRIZZLE_TIMESTAMP_DATETIME; // Return full date
216
215
    microseconds= ltime->second_part + sign*second_part;
217
216
    extra_sec= microseconds/1000000L;
218
217
    microseconds= microseconds%1000000L;
242
241
    /* Day number from year 0 to 9999-12-31 */
243
242
    if ((uint64_t) daynr > MAX_DAY_NUMBER)
244
243
      goto invalid_date;
245
 
    get_date_from_daynr((long) daynr, &ltime->year, &ltime->month, &ltime->day);
 
244
    get_date_from_daynr((long) daynr, &ltime->year, &ltime->month,
 
245
        &ltime->day);
246
246
    break;
247
247
  case INTERVAL_DAY:
248
248
  case INTERVAL_WEEK:
286
286
 
287
287
invalid_date:
288
288
  push_warning_printf(current_session, DRIZZLE_ERROR::WARN_LEVEL_WARN,
289
 
                      ER_DATETIME_FUNCTION_OVERFLOW,
290
 
                      ER(ER_DATETIME_FUNCTION_OVERFLOW),
291
 
                      "datetime");
 
289
      ER_DATETIME_FUNCTION_OVERFLOW,
 
290
      ER(ER_DATETIME_FUNCTION_OVERFLOW),
 
291
      "datetime");
292
292
null_date:
293
293
  return 1;
294
294
}