47 const char *ptr, *end;
48 MY_LOCALE *locale= session.variables.lc_time_names;
55 end= (ptr= format->c_ptr()) + format->length();
56 for (; ptr != end ; ptr++)
58 if (*ptr !=
'%' || ptr+1 == end)
66 str->append(locale->month_names->type_names[l_time->month-1], strlen(locale->month_names->type_names[l_time->month-1]));
71 str->append(locale->ab_month_names->type_names[l_time->month-1], strlen(locale->ab_month_names->type_names[l_time->month-1]));
74 if (
type == type::DRIZZLE_TIMESTAMP_TIME)
76 weekday= calc_weekday(calc_daynr(l_time->year,l_time->month,
78 str->append(locale->day_names->type_names[weekday], strlen(locale->day_names->type_names[weekday]));
81 if (
type == type::DRIZZLE_TIMESTAMP_TIME)
83 weekday=calc_weekday(calc_daynr(l_time->year,l_time->month, l_time->day),0);
84 str->append(locale->ab_day_names->type_names[weekday], strlen(locale->ab_day_names->type_names[weekday]));
87 if (
type == type::DRIZZLE_TIMESTAMP_TIME)
89 length= internal::int10_to_str(l_time->day, intbuff, 10) - intbuff;
90 str->append_with_prefill(intbuff, length, 1,
'0');
91 if (l_time->day >= 10 && l_time->day <= 19)
92 str->append(STRING_WITH_LEN(
"th"));
95 switch (l_time->day %10) {
97 str->append(STRING_WITH_LEN(
"st"));
100 str->append(STRING_WITH_LEN(
"nd"));
103 str->append(STRING_WITH_LEN(
"rd"));
106 str->append(STRING_WITH_LEN(
"th"));
112 length= internal::int10_to_str(l_time->year, intbuff, 10) - intbuff;
113 str->append_with_prefill(intbuff, length, 4,
'0');
116 length= internal::int10_to_str(l_time->year%100, intbuff, 10) - intbuff;
117 str->append_with_prefill(intbuff, length, 2,
'0');
120 length= internal::int10_to_str(l_time->month, intbuff, 10) - intbuff;
121 str->append_with_prefill(intbuff, length, 2,
'0');
124 length= internal::int10_to_str(l_time->month, intbuff, 10) - intbuff;
125 str->append_with_prefill(intbuff, length, 1,
'0');
128 length= internal::int10_to_str(l_time->day, intbuff, 10) - intbuff;
129 str->append_with_prefill(intbuff, length, 2,
'0');
132 length= internal::int10_to_str(l_time->day, intbuff, 10) - intbuff;
133 str->append_with_prefill(intbuff, length, 1,
'0');
136 length= internal::int10_to_str(l_time->second_part, intbuff, 10) - intbuff;
137 str->append_with_prefill(intbuff, length, 6,
'0');
140 length= internal::int10_to_str(l_time->hour, intbuff, 10) - intbuff;
141 str->append_with_prefill(intbuff, length, 2,
'0');
145 hours_i= (l_time->hour%24 + 11)%12+1;
146 length= internal::int10_to_str(hours_i, intbuff, 10) - intbuff;
147 str->append_with_prefill(intbuff, length, 2,
'0');
150 length= internal::int10_to_str(l_time->minute, intbuff, 10) - intbuff;
151 str->append_with_prefill(intbuff, length, 2,
'0');
154 if (
type == type::DRIZZLE_TIMESTAMP_TIME)
156 length= internal::int10_to_str(calc_daynr(l_time->year,l_time->month,
158 calc_daynr(l_time->year,1,1) + 1, intbuff, 10) - intbuff;
159 str->append_with_prefill(intbuff, length, 3,
'0');
162 length= internal::int10_to_str(l_time->hour, intbuff, 10) - intbuff;
163 str->append_with_prefill(intbuff, length, 1,
'0');
166 hours_i= (l_time->hour%24 + 11)%12+1;
167 length= internal::int10_to_str(hours_i, intbuff, 10) - intbuff;
168 str->append_with_prefill(intbuff, length, 1,
'0');
171 hours_i= l_time->hour%24;
172 str->append(hours_i < 12 ?
"AM" :
"PM",2);
175 length= snprintf(intbuff,
sizeof(intbuff),
176 ((l_time->hour % 24) < 12) ?
177 "%02d:%02d:%02d AM" :
"%02d:%02d:%02d PM",
178 (l_time->hour+11)%12+1,
181 str->append(intbuff, length);
185 length= internal::int10_to_str(l_time->second, intbuff, 10) - intbuff;
186 str->append_with_prefill(intbuff, length, 2,
'0');
189 length= snprintf(intbuff,
sizeof(intbuff),
194 str->append(intbuff, length);
200 if (
type == type::DRIZZLE_TIMESTAMP_TIME)
202 length= internal::int10_to_str(calc_week(l_time,
204 WEEK_FIRST_WEEKDAY : WEEK_MONDAY_FIRST,
206 intbuff, 10) - intbuff;
207 str->append_with_prefill(intbuff, length, 2,
'0');
214 if (
type == type::DRIZZLE_TIMESTAMP_TIME)
216 length= internal::int10_to_str(calc_week(l_time,
218 (WEEK_YEAR | WEEK_FIRST_WEEKDAY) :
219 (WEEK_YEAR | WEEK_MONDAY_FIRST)),
221 intbuff, 10) - intbuff;
222 str->append_with_prefill(intbuff, length, 2,
'0');
229 if (
type == type::DRIZZLE_TIMESTAMP_TIME)
231 (void) calc_week(l_time,
233 WEEK_YEAR | WEEK_FIRST_WEEKDAY :
234 WEEK_YEAR | WEEK_MONDAY_FIRST),
236 length= internal::int10_to_str(year, intbuff, 10) - intbuff;
237 str->append_with_prefill(intbuff, length, 4,
'0');
241 if (
type == type::DRIZZLE_TIMESTAMP_TIME)
243 weekday=calc_weekday(calc_daynr(l_time->year,l_time->month,
245 length= internal::int10_to_str(weekday, intbuff, 10) - intbuff;
246 str->append_with_prefill(intbuff, length, 1,
'0');