~drizzle-trunk/drizzle/development

« back to all changes in this revision

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

  • Committer: Monty Taylor
  • Date: 2009-01-06 18:46:25 UTC
  • mto: This revision was merged to the branch mainline in revision 762.
  • Revision ID: mordred@inaugust.com-20090106184625-kqu7nsnwjwm5jv4s
Enabled dirty_close.

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
 
20
20
#include <drizzled/server_includes.h>
21
21
#include CSTDINT_H
22
 
#include <drizzled/functions/time/add_time.h>
23
 
#include <drizzled/item/timefunc.h>
 
22
#include <drizzled/function/time/add_time.h>
 
23
#include <drizzled/function/time/make_datetime.h>
 
24
#include <drizzled/function/time/make_datetime_with_warn.h>
24
25
 
25
26
void Item_func_add_time::fix_length_and_dec()
26
27
{
51
52
 
52
53
/**
53
54
  ADDTIME(t,a) and SUBTIME(t,a) are time functions that calculate a
54
 
  time/datetime value 
 
55
  time/datetime value
55
56
 
56
57
  t: time_or_datetime_expression
57
58
  a: time_expression
58
 
  
 
59
 
59
60
  Result: Time value or datetime value
60
61
*/
61
62
 
71
72
  null_value=0;
72
73
  if (is_date)                        // TIMESTAMP function
73
74
  {
74
 
    if (get_arg0_date(&l_time1, TIME_FUZZY_DATE) || 
 
75
    if (get_arg0_date(&l_time1, TIME_FUZZY_DATE) ||
75
76
        args[1]->get_time(&l_time2) ||
76
 
        l_time1.time_type == DRIZZLE_TIMESTAMP_TIME || 
 
77
        l_time1.time_type == DRIZZLE_TIMESTAMP_TIME ||
77
78
        l_time2.time_type != DRIZZLE_TIMESTAMP_TIME)
78
79
      goto null_date;
79
80
  }
80
81
  else                                // ADDTIME function
81
82
  {
82
 
    if (args[0]->get_time(&l_time1) || 
 
83
    if (args[0]->get_time(&l_time1) ||
83
84
        args[1]->get_time(&l_time2) ||
84
85
        l_time2.time_type == DRIZZLE_TIMESTAMP_DATETIME)
85
86
      goto null_date;
87
88
  }
88
89
  if (l_time1.neg != l_time2.neg)
89
90
    l_sign= -l_sign;
90
 
  
 
91
 
91
92
  memset(&l_time3, 0, sizeof(l_time3));
92
 
  
 
93
 
93
94
  l_time3.neg= calc_time_diff(&l_time1, &l_time2, -l_sign,
94
95
                              &seconds, &microseconds);
95
96
 
117
118
      return str;
118
119
    goto null_date;
119
120
  }
120
 
  
 
121
 
121
122
  l_time3.hour+= days*24;
122
123
  if (!make_datetime_with_warn(l_time1.second_part || l_time2.second_part ?
123
124
                               TIME_MICROSECOND : TIME_ONLY,