datetime.c 327 B

123456789101112131415161718
  1. /* See LICENSE file for copyright and license details. */
  2. #include <time.h>
  3. #include "../util.h"
  4. const char *
  5. datetime(const char *fmt)
  6. {
  7. time_t t;
  8. t = time(NULL);
  9. if (!strftime(buf, sizeof(buf), fmt, localtime(&t))) {
  10. fprintf(stderr, "strftime: Result string exceeds buffer size\n");
  11. return NULL;
  12. }
  13. return buf;
  14. }