diff options
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; +} + |