datetime.c 381 B

12345678910111213141516171819
  1. /* See LICENSE file for copyright and license details. */
  2. #include <err.h>
  3. #include <time.h>
  4. #include <stdio.h>
  5. #include "../lib/util.h"
  6. void
  7. datetime(char *out, const char *fmt, uint32_t __unused _i, void __unused *_p)
  8. {
  9. time_t t;
  10. t = time(NULL);
  11. if (!strftime(out, BUFF_SZ, fmt, localtime(&t))) {
  12. warnx("strftime: Result string exceeds buffer size");
  13. ERRRET(out);
  14. }
  15. }