summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMichael Stapelberg <michael@stapelberg.de>2011-04-22 01:10:40 +0200
committerMichael Stapelberg <michael@stapelberg.de>2011-04-22 01:10:40 +0200
commit0a13d304654a63c53f9cffdcd8941b92f3a445fe (patch)
treed65f3cf89576440afaaf05ea39d84df5c470a3d0 /src
parent28934ef858e094bac998556df85a082bee923a96 (diff)
Also use the correct time for the ddate module
Diffstat (limited to 'src')
-rw-r--r--src/print_ddate.c13
1 files changed, 4 insertions, 9 deletions
diff --git a/src/print_ddate.c b/src/print_ddate.c
index 16923b2..453e5a2 100644
--- a/src/print_ddate.c
+++ b/src/print_ddate.c
@@ -164,15 +164,10 @@ int format_output(char *format, struct disc_time *dt) {
}
/* Get the current date and convert it to discordian */
-struct disc_time *get_ddate() {
- time_t current_time;
- struct tm *current_tm;
+struct disc_time *get_ddate(struct tm *current_tm) {
static struct disc_time dt;
- if ((current_time = time(NULL)) == (time_t)-1)
- return NULL;
-
- if ((current_tm = localtime(&current_time)) == NULL)
+ if (current_tm == NULL)
return NULL;
/* 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;
}
-void print_ddate(const char *format) {
+void print_ddate(const char *format, struct tm *current_tm) {
static char *form = NULL;
struct disc_time *dt;
- if ((dt = get_ddate()) == NULL)
+ if ((dt = get_ddate(current_tm)) == NULL)
return;
if (form == NULL)
if ((form = malloc(strlen(format) + 1)) == NULL)