From ef4b84d6d43b7347e741e6307267df54c3e34ca5 Mon Sep 17 00:00:00 2001 From: Dan Winship Date: Tue, 23 Jul 2002 13:57:51 +0000 Subject: Replace a bunch of old gnomecal functions with the functionally identical * cal-util/timeutil.c: Replace a bunch of old gnomecal functions with the functionally identical ones from Connector. svn path=/trunk/; revision=17548 --- calendar/ChangeLog | 3 +++ calendar/cal-util/timeutil.c | 45 +++++++++++--------------------------------- 2 files changed, 14 insertions(+), 34 deletions(-) diff --git a/calendar/ChangeLog b/calendar/ChangeLog index af75d5fda3..7a88b874ad 100644 --- a/calendar/ChangeLog +++ b/calendar/ChangeLog @@ -6,6 +6,9 @@ backend shouldn't be calling functions from the existing backends anyway so there's no reason to install them. + * cal-util/timeutil.c: Replace a bunch of old gnomecal functions + with the functionally identical ones from Connector. + 2002-07-18 Rodrigo Moya * importers/icalendar-importer.c (get_uri_from_folder_path): if diff --git a/calendar/cal-util/timeutil.c b/calendar/cal-util/timeutil.c index 3dcf8dc384..f909022565 100644 --- a/calendar/cal-util/timeutil.c +++ b/calendar/cal-util/timeutil.c @@ -1,7 +1,6 @@ /* Miscellaneous time-related utilities * - * Copyright (C) 1998 The Free Software Foundation - * Copyright (C) 2000 Ximian, Inc. + * Copyright (C) 2000, 2001 Ximian, Inc. * * Authors: Federico Mena * Miguel de Icaza @@ -38,16 +37,6 @@ static const int days_in_month[12] = { * icaltimetype values rather than time_t values wherever possible. **************************************************************************/ -static void -print_time_t (time_t t) -{ - struct tm *tm = localtime (&t); - - printf ("%d/%02d/%02d %02d:%02d:%02d", - 1900 + tm->tm_year, tm->tm_mon+1, tm->tm_mday, - tm->tm_hour, tm->tm_min, tm->tm_sec); -} - /* Adds a day onto the time, using local time. Note that if clocks go forward due to daylight savings time, there are some non-existent local times, so the hour may be changed to make it a @@ -58,21 +47,13 @@ print_time_t (time_t t) time_t time_add_day (time_t time, int days) { - struct tm *tm = localtime (&time); - time_t new_time; + struct tm *tm; + tm = localtime (&time); tm->tm_mday += days; tm->tm_isdst = -1; - if ((new_time = mktime (tm)) == -1) { - g_message ("time_add_day(): mktime() could not handling adding %d days with\n", - days); - print_time_t (time); - printf ("\n"); - return time; - } - - return new_time; + return mktime (tm); } time_t @@ -88,9 +69,7 @@ time_day_begin (time_t t) struct tm tm; tm = *localtime (&t); - tm.tm_hour = 0; - tm.tm_min = 0; - tm.tm_sec = 0; + tm.tm_hour = tm.tm_min = tm.tm_sec = 0; tm.tm_isdst = -1; return mktime (&tm); @@ -103,10 +82,8 @@ time_day_end (time_t t) struct tm tm; tm = *localtime (&t); + tm.tm_hour = tm.tm_min = tm.tm_sec = 0; tm.tm_mday++; - tm.tm_hour = 0; - tm.tm_min = 0; - tm.tm_sec = 0; tm.tm_isdst = -1; return mktime (&tm); @@ -454,12 +431,12 @@ time_leap_years_up_to (int year) char * isodate_from_time_t (time_t t) { - struct tm *tm; - char isotime[40]; + gchar *ret; + + ret = g_malloc (17); /* 4+2+2+1+2+2+2+1 + 1 */ + strftime (ret, 17, "%Y%m%dT%H%M%SZ", gmtime (&t)); - tm = gmtime (&t); - strftime (isotime, sizeof (isotime)-1, "%Y%m%dT%H%M%SZ", tm); - return g_strdup (isotime); + return ret; } /** -- cgit