From bacbb085895ae69e7f443cc39e04b686128a63a3 Mon Sep 17 00:00:00 2001 From: Arturo Espinosa Date: Sat, 4 Apr 1998 03:29:36 +0000 Subject: more and more fixes -mig svn path=/trunk/; revision=104 --- calendar/timeutil.c | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) (limited to 'calendar/timeutil.c') diff --git a/calendar/timeutil.c b/calendar/timeutil.c index 3a78bf2b4f..20d6fa7990 100644 --- a/calendar/timeutil.c +++ b/calendar/timeutil.c @@ -37,7 +37,7 @@ print_time_t (time_t t) struct tm *tm = localtime (&t); printf ("TIEMPO: %d/%d/%d %d:%d:%d\n", - tm->tm_mday, tm->tm_mon, tm->tm_year, + tm->tm_mon+1, tm->tm_mday, tm->tm_year, tm->tm_hour, tm->tm_min, tm->tm_sec); } @@ -89,17 +89,32 @@ format_simple_hour (int hour, int use_am_pm) } time_t -time_add_week (time_t time, int weeks) -{ -} - -time_t -time_add_day (time_t time, int weeks) +time_add_day (time_t time, int days) { + struct tm *tm = localtime (&time); + time_t new_time; + + tm->tm_mday += days; + if ((new_time = mktime (tm)) == -1){ + g_warning ("mktime could not handling adding a day with\n"); + print_time_t (time); + return time; + } + return new_time; } time_t time_add_year (time_t time, int years) { + struct tm *tm = localtime (&time); + time_t new_time; + + tm->tm_year += years; + if ((new_time = mktime (tm)) == -1){ + g_warning ("mktime could not handling adding a year with\n"); + print_time_t (time); + return time; + } + return new_time; } -- cgit v1.2.3