| 378 | } |
| 379 | |
| 380 | const char* query::to_date(time_t t, string& out, |
| 381 | const char* fmt /* = "%Y-%m-%d %H:%M:%S" */) |
| 382 | { |
| 383 | char buf[256]; |
| 384 | |
| 385 | if (fmt == NULL || *fmt == 0) { |
| 386 | fmt = "%Y-%m-%d %H:%M:%S"; |
| 387 | } |
| 388 | |
| 389 | struct tm local; |
| 390 | |
| 391 | if (acl_localtime_r(&t, &local) == NULL) { |
| 392 | logger_error("localtime_s failed, t: %ld", (long) t); |
| 393 | return NULL; |
| 394 | } |
| 395 | |
| 396 | if (strftime(buf, sizeof(buf), fmt, &local) == 0) { |
| 397 | logger_error("strftime failed, t: %ld, fmt: %s", |
| 398 | (long) t, fmt); |
| 399 | return NULL; |
| 400 | } |
| 401 | |
| 402 | out = buf; |
| 403 | return out.c_str(); |
| 404 | } |
| 405 | |
| 406 | } // namespace acl |
| 407 |
nothing calls this directly
no test coverage detected