Introduction
Introduction Statistics Contact Development Disclaimer Help
date.c - spoon - set dwm status
git clone git://git.codemadness.org/spoon
Log
Files
Refs
LICENSE
---
date.c (516B)
---
1 #include <sys/types.h>
2
3 #include <stdio.h>
4 #include <stdlib.h>
5 #include <time.h>
6
7 #include "types.h"
8
9 int
10 dateread(void *arg, char *buf, size_t len)
11 {
12 struct datearg *datearg = arg;
13 struct tm *now;
14 char *oldtz;
15 time_t t;
16
17 oldtz = getenv("TZ");
18 if (datearg->tz != NULL && setenv("TZ", datearg->tz, 1) == 0)
19 tzset();
20 t = time(NULL);
21 now = localtime(&t);
22 if (oldtz != NULL)
23 setenv("TZ", oldtz, 1);
24 else
25 unsetenv("TZ");
26 if (now == NULL)
27 return -1;
28 strftime(buf, len, datearg->fmt, now);
29 return 0;
30 }
You are viewing proxied material from codemadness.org. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.