~drizzle-developers/ubuntu/natty/drizzle/natty

« back to all changes in this revision

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

  • Committer: Monty Taylor
  • Date: 2010-03-03 19:27:30 UTC
  • mto: (1308.1.2 trunk)
  • mto: This revision was merged to the branch mainline in revision 1278.
  • Revision ID: mordred@inaugust.com-20100303192730-o2o3nmp0lzhuatbe
Tags: upstream-2010.03.1317
ImportĀ upstreamĀ versionĀ 2010.03.1317

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
 
28
28
using namespace std;
29
29
 
 
30
namespace drizzled
 
31
{
30
32
 
31
33
/**
32
34
  Create a formated date/time value in a string.
91
93
      case 'D':
92
94
        if (type == DRIZZLE_TIMESTAMP_TIME)
93
95
          return 1;
94
 
        length= int10_to_str(l_time->day, intbuff, 10) - intbuff;
 
96
        length= internal::int10_to_str(l_time->day, intbuff, 10) - intbuff;
95
97
        str->append_with_prefill(intbuff, length, 1, '0');
96
98
        if (l_time->day >= 10 &&  l_time->day <= 19)
97
99
          str->append(STRING_WITH_LEN("th"));
114
116
        }
115
117
        break;
116
118
      case 'Y':
117
 
        length= int10_to_str(l_time->year, intbuff, 10) - intbuff;
 
119
        length= internal::int10_to_str(l_time->year, intbuff, 10) - intbuff;
118
120
        str->append_with_prefill(intbuff, length, 4, '0');
119
121
        break;
120
122
      case 'y':
121
 
        length= int10_to_str(l_time->year%100, intbuff, 10) - intbuff;
 
123
        length= internal::int10_to_str(l_time->year%100, intbuff, 10) - intbuff;
122
124
        str->append_with_prefill(intbuff, length, 2, '0');
123
125
        break;
124
126
      case 'm':
125
 
        length= int10_to_str(l_time->month, intbuff, 10) - intbuff;
 
127
        length= internal::int10_to_str(l_time->month, intbuff, 10) - intbuff;
126
128
        str->append_with_prefill(intbuff, length, 2, '0');
127
129
        break;
128
130
      case 'c':
129
 
        length= int10_to_str(l_time->month, intbuff, 10) - intbuff;
 
131
        length= internal::int10_to_str(l_time->month, intbuff, 10) - intbuff;
130
132
        str->append_with_prefill(intbuff, length, 1, '0');
131
133
        break;
132
134
      case 'd':
133
 
        length= int10_to_str(l_time->day, intbuff, 10) - intbuff;
 
135
        length= internal::int10_to_str(l_time->day, intbuff, 10) - intbuff;
134
136
        str->append_with_prefill(intbuff, length, 2, '0');
135
137
        break;
136
138
      case 'e':
137
 
        length= int10_to_str(l_time->day, intbuff, 10) - intbuff;
 
139
        length= internal::int10_to_str(l_time->day, intbuff, 10) - intbuff;
138
140
        str->append_with_prefill(intbuff, length, 1, '0');
139
141
        break;
140
142
      case 'f':
141
 
        length= int10_to_str(l_time->second_part, intbuff, 10) - intbuff;
 
143
        length= internal::int10_to_str(l_time->second_part, intbuff, 10) - intbuff;
142
144
        str->append_with_prefill(intbuff, length, 6, '0');
143
145
        break;
144
146
      case 'H':
145
 
        length= int10_to_str(l_time->hour, intbuff, 10) - intbuff;
 
147
        length= internal::int10_to_str(l_time->hour, intbuff, 10) - intbuff;
146
148
        str->append_with_prefill(intbuff, length, 2, '0');
147
149
        break;
148
150
      case 'h':
149
151
      case 'I':
150
152
        hours_i= (l_time->hour%24 + 11)%12+1;
151
 
        length= int10_to_str(hours_i, intbuff, 10) - intbuff;
 
153
        length= internal::int10_to_str(hours_i, intbuff, 10) - intbuff;
152
154
        str->append_with_prefill(intbuff, length, 2, '0');
153
155
        break;
154
156
      case 'i':                                 /* minutes */
155
 
        length= int10_to_str(l_time->minute, intbuff, 10) - intbuff;
 
157
        length= internal::int10_to_str(l_time->minute, intbuff, 10) - intbuff;
156
158
        str->append_with_prefill(intbuff, length, 2, '0');
157
159
        break;
158
160
      case 'j':
159
161
        if (type == DRIZZLE_TIMESTAMP_TIME)
160
162
          return 1;
161
 
        length= int10_to_str(calc_daynr(l_time->year,l_time->month,
 
163
        length= internal::int10_to_str(calc_daynr(l_time->year,l_time->month,
162
164
                                        l_time->day) -
163
165
                     calc_daynr(l_time->year,1,1) + 1, intbuff, 10) - intbuff;
164
166
        str->append_with_prefill(intbuff, length, 3, '0');
165
167
        break;
166
168
      case 'k':
167
 
        length= int10_to_str(l_time->hour, intbuff, 10) - intbuff;
 
169
        length= internal::int10_to_str(l_time->hour, intbuff, 10) - intbuff;
168
170
        str->append_with_prefill(intbuff, length, 1, '0');
169
171
        break;
170
172
      case 'l':
171
173
        hours_i= (l_time->hour%24 + 11)%12+1;
172
 
        length= int10_to_str(hours_i, intbuff, 10) - intbuff;
 
174
        length= internal::int10_to_str(hours_i, intbuff, 10) - intbuff;
173
175
        str->append_with_prefill(intbuff, length, 1, '0');
174
176
        break;
175
177
      case 'p':
187
189
        break;
188
190
      case 'S':
189
191
      case 's':
190
 
        length= int10_to_str(l_time->second, intbuff, 10) - intbuff;
 
192
        length= internal::int10_to_str(l_time->second, intbuff, 10) - intbuff;
191
193
        str->append_with_prefill(intbuff, length, 2, '0');
192
194
        break;
193
195
      case 'T':
204
206
        uint32_t year;
205
207
        if (type == DRIZZLE_TIMESTAMP_TIME)
206
208
          return 1;
207
 
        length= int10_to_str(calc_week(l_time,
 
209
        length= internal::int10_to_str(calc_week(l_time,
208
210
                                       (*ptr) == 'U' ?
209
211
                                       WEEK_FIRST_WEEKDAY : WEEK_MONDAY_FIRST,
210
212
                                       &year),
218
220
        uint32_t year;
219
221
        if (type == DRIZZLE_TIMESTAMP_TIME)
220
222
          return 1;
221
 
        length= int10_to_str(calc_week(l_time,
 
223
        length= internal::int10_to_str(calc_week(l_time,
222
224
                                       ((*ptr) == 'V' ?
223
225
                                        (WEEK_YEAR | WEEK_FIRST_WEEKDAY) :
224
226
                                        (WEEK_YEAR | WEEK_MONDAY_FIRST)),
238
240
                          WEEK_YEAR | WEEK_FIRST_WEEKDAY :
239
241
                          WEEK_YEAR | WEEK_MONDAY_FIRST),
240
242
                         &year);
241
 
        length= int10_to_str(year, intbuff, 10) - intbuff;
 
243
        length= internal::int10_to_str(year, intbuff, 10) - intbuff;
242
244
        str->append_with_prefill(intbuff, length, 4, '0');
243
245
      }
244
246
      break;
247
249
          return 1;
248
250
        weekday=calc_weekday(calc_daynr(l_time->year,l_time->month,
249
251
                                        l_time->day),1);
250
 
        length= int10_to_str(weekday, intbuff, 10) - intbuff;
 
252
        length= internal::int10_to_str(weekday, intbuff, 10) - intbuff;
251
253
        str->append_with_prefill(intbuff, length, 1, '0');
252
254
        break;
253
255
 
432
434
  return 0;
433
435
}
434
436
 
 
437
} /* namespace drizzled */