~drizzle-trunk/drizzle/development

« back to all changes in this revision

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

  • Committer: Brian Aker
  • Date: 2011-01-20 15:27:43 UTC
  • mfrom: (2097.1.7 drizzle-build)
  • Revision ID: brian@tangent.org-20110120152743-x88aq1sj1k9andwm
Merge of all of the time fixes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
36
36
*/
37
37
 
38
38
static bool make_date_time(String *format, type::Time *l_time,
39
 
                           enum enum_drizzle_timestamp_type type, String *str)
 
39
                           type::timestamp_t type, String *str)
40
40
{
41
41
  char intbuff[15];
42
42
  uint32_t hours_i;
74
74
                    system_charset_info);
75
75
        break;
76
76
      case 'W':
77
 
        if (type == DRIZZLE_TIMESTAMP_TIME)
 
77
        if (type == type::DRIZZLE_TIMESTAMP_TIME)
78
78
          return 1;
79
79
        weekday= calc_weekday(calc_daynr(l_time->year,l_time->month,
80
80
                              l_time->day),0);
83
83
                    system_charset_info);
84
84
        break;
85
85
      case 'a':
86
 
        if (type == DRIZZLE_TIMESTAMP_TIME)
 
86
        if (type == type::DRIZZLE_TIMESTAMP_TIME)
87
87
          return 1;
88
88
        weekday=calc_weekday(calc_daynr(l_time->year,l_time->month,
89
89
                             l_time->day),0);
92
92
                    system_charset_info);
93
93
        break;
94
94
      case 'D':
95
 
        if (type == DRIZZLE_TIMESTAMP_TIME)
 
95
        if (type == type::DRIZZLE_TIMESTAMP_TIME)
96
96
          return 1;
97
97
        length= internal::int10_to_str(l_time->day, intbuff, 10) - intbuff;
98
98
        str->append_with_prefill(intbuff, length, 1, '0');
159
159
        str->append_with_prefill(intbuff, length, 2, '0');
160
160
        break;
161
161
      case 'j':
162
 
        if (type == DRIZZLE_TIMESTAMP_TIME)
 
162
        if (type == type::DRIZZLE_TIMESTAMP_TIME)
163
163
          return 1;
164
164
        length= internal::int10_to_str(calc_daynr(l_time->year,l_time->month,
165
165
                                        l_time->day) -
205
205
      case 'u':
206
206
      {
207
207
        uint32_t year;
208
 
        if (type == DRIZZLE_TIMESTAMP_TIME)
 
208
        if (type == type::DRIZZLE_TIMESTAMP_TIME)
209
209
          return 1;
210
210
        length= internal::int10_to_str(calc_week(l_time,
211
211
                                       (*ptr) == 'U' ?
219
219
      case 'V':
220
220
      {
221
221
        uint32_t year;
222
 
        if (type == DRIZZLE_TIMESTAMP_TIME)
 
222
        if (type == type::DRIZZLE_TIMESTAMP_TIME)
223
223
          return 1;
224
224
        length= internal::int10_to_str(calc_week(l_time,
225
225
                                       ((*ptr) == 'V' ?
234
234
      case 'X':
235
235
      {
236
236
        uint32_t year;
237
 
        if (type == DRIZZLE_TIMESTAMP_TIME)
 
237
        if (type == type::DRIZZLE_TIMESTAMP_TIME)
238
238
          return 1;
239
239
        (void) calc_week(l_time,
240
240
                         ((*ptr) == 'X' ?
246
246
      }
247
247
      break;
248
248
      case 'w':
249
 
        if (type == DRIZZLE_TIMESTAMP_TIME)
 
249
        if (type == type::DRIZZLE_TIMESTAMP_TIME)
250
250
          return 1;
251
251
        weekday=calc_weekday(calc_daynr(l_time->year,l_time->month,
252
252
                                        l_time->day),1);
410
410
    goto null_date;
411
411
 
412
412
  if (fixed_length)
413
 
    size=max_length;
 
413
    size= max_length;
414
414
  else
415
 
    size=format_length(format);
 
415
    size= format_length(format);
416
416
 
417
 
  if (size < MAX_DATE_STRING_REP_LENGTH)
418
 
    size= MAX_DATE_STRING_REP_LENGTH;
 
417
  if (size < type::Time::MAX_STRING_LENGTH)
 
418
    size= type::Time::MAX_STRING_LENGTH;
419
419
 
420
420
  if (format == str)
421
421
    str= &value;                                // Save result here
426
426
  /* Create the result string */
427
427
  str->set_charset(collation.collation);
428
428
  if (not make_date_time(format, &l_time,
429
 
                         is_time_format ? DRIZZLE_TIMESTAMP_TIME :
430
 
                         DRIZZLE_TIMESTAMP_DATE,
 
429
                         is_time_format ? type::DRIZZLE_TIMESTAMP_TIME :
 
430
                         type::DRIZZLE_TIMESTAMP_DATE,
431
431
                         str))
432
432
    return str;
433
433