diff options
author | ZoRo <dos21h@gmail.com> | 2020-04-05 16:31:20 +0100 |
---|---|---|
committer | ZoRo <dos21h@gmail.com> | 2020-04-05 16:31:20 +0100 |
commit | de58c2e89c6d38ae21e12b83902defa171b0b635 (patch) | |
tree | 632d661b8f3eb686bfd1788e7148044ef1fe8431 /status/date.c | |
download | dwmstatus-pixel-master.tar.gz dwmstatus-pixel-master.zip |
Diffstat (limited to 'status/date.c')
-rw-r--r-- | status/date.c | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/status/date.c b/status/date.c new file mode 100644 index 0000000..f06c61d --- /dev/null +++ b/status/date.c @@ -0,0 +1,39 @@ +#include "kconfig.h" +#include "dwmstatus.h" + +int print_date( bbuf *buf ) +{ + ASSERT( buf != NULL ); + + int str_size=0; + if ( buf->size < 1 ) + { + buf->size = 1024; + buf->str = malloc( buf->size ); + ASSERT( buf->str != NULL ); + } + + time_t tim; + struct tm *timtm; + + memset(buf->str, 0, buf->size); + time( &tim ); + timtm = localtime( &tim ); + if (timtm == NULL) + { + perror("localtime"); + } + +#ifdef CONFIG_STATUS_UTF8 + buf->str[0] = 0xef; + buf->str[1] = 0x81; + buf->str[2] = 0xb3; + str_size = 3; +#endif + + + strftime(&buf->str[str_size], buf->size-1-str_size," %d%b%Y", timtm); + + return 0; +} + |