diff options
Diffstat (limited to 'src/config_time.c')
-rw-r--r-- | src/config_time.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/config_time.c b/src/config_time.c index 39c8427..a480a60 100644 --- a/src/config_time.c +++ b/src/config_time.c @@ -23,6 +23,12 @@ void config_time_init(struct node* n) { n->loadfunc = &config_time_load; n->loadkey = &load_time_key; + if(getenv("LANG") != NULL) { + strcpy(( (struct config_time*) n->data)->locale, getenv("LANG")); + } else { + strcpy(( (struct config_time*) n->data)->locale, "POSIX"); + } + strcpy(((struct config_time*) n->data)->fmt, "%T"); } @@ -32,6 +38,8 @@ void load_time_key(struct node* n, char* key, char* val) { strcpy(((struct config_time*) n->data)->tz, val); else if(strcmp(key, "fmt") == 0) strcpy(((struct config_time*) n->data)->fmt, val); + else if(strcmp(key, "locale") == 0) + strcpy(((struct config_time*) n->data)->locale, val); else printf("ERROR: Unknown time key %s\n", key); } @@ -42,6 +50,8 @@ int config_time_load(struct node* n) { struct tm* info; setenv("TZ", ((struct config_time*)n->data)->tz, 1); + setlocale(LC_ALL, ((struct config_time*)n->data)->locale); + time(&timep); info = localtime(&timep); |