diff options
-rw-r--r-- | src/config_date.c | 30 | ||||
-rw-r--r-- | src/config_date.h | 6 |
2 files changed, 7 insertions, 29 deletions
diff --git a/src/config_date.c b/src/config_date.c index 0db56ef..7a4753b 100644 --- a/src/config_date.c +++ b/src/config_date.c @@ -16,32 +16,16 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include "config_date.h" +#include "config_time.h" void config_date_init(struct node* n) { - n->data = malloc(sizeof(struct config_date)); + n->data = malloc(sizeof(struct config_time)); n->type = CTYPE_DATE; - n->loadfunc = &config_date_load; - n->loadkey = &load_date_key; -} + n->loadfunc = &config_time_load; + n->loadkey = &load_time_key; -void load_date_key(struct node* n, char* key, char* val) { - if(strcmp(key, "tz") == 0) - strcpy(((struct config_date*) n->data)->tz, val); - else - printf("ERROR: Unknown time key %s\n", key); + strcpy(((struct config_time*) n->data)->fmt, "%F"); } -int config_date_load(struct node* n) { - char buf[256]; - time_t timep; - struct tm* info; - - setenv("TZ", ((struct config_date*)n->data)->tz, 1); - time(&timep); - info = localtime(&timep); - - strftime(buf, 256, "%F", info); - strcpy(n->label, buf); - strcpy(n->color, C_LGREY); - return 0; -} +// All functions are provided by config_time, since date is just a config_time +// with a different date format. diff --git a/src/config_date.h b/src/config_date.h index 41b1069..4a7660e 100644 --- a/src/config_date.h +++ b/src/config_date.h @@ -25,12 +25,6 @@ #include "common.h" #include "config_node.h" -struct config_date { - char tz[64]; -}; - void config_date_init(struct node*); -void load_date_key(struct node*, char*, char*); -int config_date_load(struct node*); #endif |