MCPcopy Create free account
hub / github.com/acl-dev/acl / to_date

Method to_date

lib_acl_cpp/src/db/query.cpp:380–404  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

378}
379
380const 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

Callers

nothing calls this directly

Calls 2

acl_localtime_rFunction · 0.85
c_strMethod · 0.45

Tested by

no test coverage detected