| 233 | // Offsets: 01234567890123456789012345678 |
| 234 | |
| 235 | int TimestampParser::FormatDefault(const date& d, const time_duration& t, char* dst) { |
| 236 | if (UNLIKELY(d.is_special() || t.is_special())) return -1; |
| 237 | const auto ymd = d.year_month_day(); |
| 238 | ZeroPad(dst, ymd.year, 4); |
| 239 | ZeroPad(dst + 5, ymd.month, 2); |
| 240 | ZeroPad(dst + 8, ymd.day, 2); |
| 241 | const auto tot_sec = t.total_seconds(); |
| 242 | ZeroPad(dst + 11, tot_sec / 3600, 2); |
| 243 | ZeroPad(dst + 14, (tot_sec / 60) % 60, 2); |
| 244 | ZeroPad(dst + 17, tot_sec % 60, 2); |
| 245 | dst[7] = dst[4] = '-'; |
| 246 | dst[10] = ' '; |
| 247 | dst[16] = dst[13] = ':'; |
| 248 | |
| 249 | if (LIKELY(t.fractional_seconds() > 0)) { |
| 250 | dst[19] = '.'; |
| 251 | ZeroPad(dst + 20, t.fractional_seconds(), 9); |
| 252 | return SimpleDateFormatTokenizer::DEFAULT_DATE_TIME_FMT_LEN; |
| 253 | } |
| 254 | return SimpleDateFormatTokenizer::DEFAULT_SHORT_DATE_TIME_FMT_LEN; |
| 255 | } |
| 256 | |
| 257 | int TimestampParser::Format(const DateTimeFormatContext& dt_ctx, const date& d, |
| 258 | const time_duration& t, int max_length, char* dst) { |