slstatus

Unnamed repository; edit this file 'description' to name the repository.
git clone https://git.beauhilton.com/slstatus.git
Log | Files | Refs | README | LICENSE

datetime.c (333B)


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