Also use the correct time for the ddate module
This commit is contained in:
parent
28934ef858
commit
0a13d30465
@ -360,7 +360,7 @@ int main(int argc, char *argv[]) {
|
|||||||
print_time(cfg_getstr(sec, "format"), current_tm);
|
print_time(cfg_getstr(sec, "format"), current_tm);
|
||||||
|
|
||||||
CASE_SEC("ddate")
|
CASE_SEC("ddate")
|
||||||
print_ddate(cfg_getstr(sec, "format"));
|
print_ddate(cfg_getstr(sec, "format"), current_tm);
|
||||||
|
|
||||||
CASE_SEC_TITLE("volume")
|
CASE_SEC_TITLE("volume")
|
||||||
print_volume(cfg_getstr(sec, "format"),
|
print_volume(cfg_getstr(sec, "format"),
|
||||||
|
@ -63,7 +63,7 @@ void print_ipv6_info(const char *format_up, const char *format_down);
|
|||||||
void print_disk_info(const char *path, const char *format);
|
void print_disk_info(const char *path, const char *format);
|
||||||
void print_battery_info(int number, const char *format, bool last_full_capacity);
|
void print_battery_info(int number, const char *format, bool last_full_capacity);
|
||||||
void print_time(const char *format, struct tm *current_tm);
|
void print_time(const char *format, struct tm *current_tm);
|
||||||
void print_ddate(const char *format);
|
void print_ddate(const char *format, struct tm *current_tm);
|
||||||
const char *get_ip_addr();
|
const char *get_ip_addr();
|
||||||
void print_wireless_info(const char *interface, const char *format_up, const char *format_down);
|
void print_wireless_info(const char *interface, const char *format_up, const char *format_down);
|
||||||
void print_run_watch(const char *title, const char *pidfile, const char *format);
|
void print_run_watch(const char *title, const char *pidfile, const char *format);
|
||||||
|
@ -164,15 +164,10 @@ int format_output(char *format, struct disc_time *dt) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Get the current date and convert it to discordian */
|
/* Get the current date and convert it to discordian */
|
||||||
struct disc_time *get_ddate() {
|
struct disc_time *get_ddate(struct tm *current_tm) {
|
||||||
time_t current_time;
|
|
||||||
struct tm *current_tm;
|
|
||||||
static struct disc_time dt;
|
static struct disc_time dt;
|
||||||
|
|
||||||
if ((current_time = time(NULL)) == (time_t)-1)
|
if (current_tm == NULL)
|
||||||
return NULL;
|
|
||||||
|
|
||||||
if ((current_tm = localtime(¤t_time)) == NULL)
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
/* We have to know, whether we have to insert St. Tib's Day, so whether it's a leap
|
/* We have to know, whether we have to insert St. Tib's Day, so whether it's a leap
|
||||||
@ -197,10 +192,10 @@ struct disc_time *get_ddate() {
|
|||||||
return &dt;
|
return &dt;
|
||||||
}
|
}
|
||||||
|
|
||||||
void print_ddate(const char *format) {
|
void print_ddate(const char *format, struct tm *current_tm) {
|
||||||
static char *form = NULL;
|
static char *form = NULL;
|
||||||
struct disc_time *dt;
|
struct disc_time *dt;
|
||||||
if ((dt = get_ddate()) == NULL)
|
if ((dt = get_ddate(current_tm)) == NULL)
|
||||||
return;
|
return;
|
||||||
if (form == NULL)
|
if (form == NULL)
|
||||||
if ((form = malloc(strlen(format) + 1)) == NULL)
|
if ((form = malloc(strlen(format) + 1)) == NULL)
|
||||||
|
Loading…
Reference in New Issue
Block a user