[evolution-data-server/wip/mcrha/libical-glib] Changes for e-cal-time-util.c/.h



commit 4f2e833dc56a987663260fd8f7fc43df53840666
Author: Milan Crha <mcrha redhat com>
Date:   Wed Feb 6 19:57:34 2019 +0100

    Changes for e-cal-time-util.c/.h

 src/calendar/libecal/e-cal-time-util.c | 334 +++++++++++++++++++--------------
 src/calendar/libecal/e-cal-time-util.h |  81 +++++---
 2 files changed, 241 insertions(+), 174 deletions(-)
---
diff --git a/src/calendar/libecal/e-cal-time-util.c b/src/calendar/libecal/e-cal-time-util.c
index 22649c588..7aae2d1a5 100644
--- a/src/calendar/libecal/e-cal-time-util.c
+++ b/src/calendar/libecal/e-cal-time-util.c
@@ -23,7 +23,6 @@
 #include <ctype.h>
 #include "e-cal-time-util.h"
 
-
 #ifdef G_OS_WIN32
 #ifdef gmtime_r
 #undef gmtime_r
@@ -50,7 +49,7 @@ static const gint days_in_month[12] = {
  *
  * NOTE: these use the Unix timezone functions like mktime() and localtime()
  * and so should not be used in Evolution. New Evolution code should use
- * icaltimetype values rather than time_t values wherever possible.
+ * ICalTimetype values rather than time_t values wherever possible.
  **************************************************************************/
 
 /**
@@ -142,7 +141,7 @@ time_day_end (time_t t)
  * time_t manipulation functions, using timezones in libical.
  *
  * NOTE: these are only here to make the transition to the timezone
- * functions easier. New code should use icaltimetype values rather than
+ * functions easier. New code should use ICalTimetype values rather than
  * time_t values wherever possible.
  **************************************************************************/
 
@@ -155,26 +154,31 @@ time_day_end (time_t t)
  * Adds or subtracts a number of days to/from the given time_t value, using
  * the given timezone.
  * NOTE: this function is only here to make the transition to the timezone
- * functions easier. New code should use icaltimetype values and
- * icaltime_adjust() to add or subtract days, hours, minutes & seconds.
+ * functions easier. New code should use ICalTimetype values and
+ * i_cal_time_adjust() to add or subtract days, hours, minutes & seconds.
  *
  * Returns: a time_t value containing @time plus the days added.
  */
 time_t
 time_add_day_with_zone (time_t time,
-                        gint days,
-                        icaltimezone *zone)
+                       gint days,
+                       const ICalTimezone *zone)
 {
-       struct icaltimetype tt;
+       ICalTimetype *tt;
+       time_t res;
 
        /* Convert to an icaltimetype. */
-       tt = icaltime_from_timet_with_zone (time, FALSE, zone);
+       tt = i_cal_time_from_timet_with_zone (time, FALSE, (ICalTimezone *) zone);
 
        /* Add/subtract the number of days. */
-       icaltime_adjust (&tt, days, 0, 0, 0);
+       i_cal_time_adjust (tt, days, 0, 0, 0);
 
        /* Convert back to a time_t. */
-       return icaltime_as_timet_with_zone (tt, zone);
+       res = i_cal_time_as_timet_with_zone (tt, (ICalTimezone *) zone);
+
+       g_object_unref (tt);
+
+       return res;
 }
 
 /**
@@ -186,15 +190,15 @@ time_add_day_with_zone (time_t time,
  * Adds or subtracts a number of weeks to/from the given time_t value, using
  * the given timezone.
  * NOTE: this function is only here to make the transition to the timezone
- * functions easier. New code should use icaltimetype values and
- * icaltime_adjust() to add or subtract days, hours, minutes & seconds.
+ * functions easier. New code should use ICalTimetype values and
+ * i_cal_time_adjust() to add or subtract days, hours, minutes & seconds.
  *
  * Returns: a time_t value containing @time plus the weeks added.
  */
 time_t
 time_add_week_with_zone (time_t time,
-                         gint weeks,
-                         icaltimezone *zone)
+                        gint weeks,
+                        const ICalTimezone *zone)
 {
        return time_add_day_with_zone (time, weeks * 7, zone);
 }
@@ -213,42 +217,49 @@ time_add_week_with_zone (time_t time,
  * down to the last day in the month, e.g. 28th Feb (or 29th in a leap year.)
  *
  * NOTE: this function is only here to make the transition to the timezone
- * functions easier. New code should use icaltimetype values and
- * icaltime_adjust() to add or subtract days, hours, minutes & seconds.
+ * functions easier. New code should use ICalTimetype values and
+ * i_cal_time_adjust() to add or subtract days, hours, minutes & seconds.
  *
  * Returns: a time_t value containing @time plus the months added.
  */
 time_t
 time_add_month_with_zone (time_t time,
-                          gint months,
-                          icaltimezone *zone)
+                         gint months,
+                         const ICalTimezone *zone)
 {
-       struct icaltimetype tt;
+       ICalTimetype *tt, *normtt;
        gint day, days_in_month;
+       time_t res;
 
        /* Convert to an icaltimetype. */
-       tt = icaltime_from_timet_with_zone (time, FALSE, zone);
+       tt = i_cal_time_from_timet_with_zone (time, FALSE, (ICalTimezone *) zone);
 
        /* Add on the number of months. */
-       tt.month += months;
+       i_cal_timetype_set_month (tt, i_cal_timetype_get_month (tt) + months);
 
        /* Save the day, and set it to 1, so we don't overflow into the next
         * month. */
-       day = tt.day;
-       tt.day = 1;
+       day = i_cal_timetype_get_day (tt);
+       i_cal_timetype_set_day (tt, 1);
 
        /* Normalize it, fixing any month overflow. */
-       tt = icaltime_normalize (tt);
+       normtt = i_cal_time_normalize (tt);
+       g_object_unref (tt);
+       tt = normtt;
 
        /* If we go past the end of a month, set it to the last day. */
-       days_in_month = time_days_in_month (tt.year, tt.month - 1);
+       days_in_month = time_days_in_month (i_cal_timetype_get_year (tt), i_cal_timetype_get_month (tt) - 1);
        if (day > days_in_month)
                day = days_in_month;
 
-       tt.day = day;
+       i_cal_timetype_set_day (tt, day);
 
        /* Convert back to a time_t. */
-       return icaltime_as_timet_with_zone (tt, zone);
+       res = i_cal_time_as_timet_with_zone (tt, (ICalTimezone *) zone);
+
+       g_object_unref (tt);
+
+       return res;
 }
 
 /**
@@ -259,29 +270,34 @@ time_add_month_with_zone (time_t time,
  * Returns the start of the year containing the given time_t, using the given
  * timezone.
  * NOTE: this function is only here to make the transition to the timezone
- * functions easier. New code should use icaltimetype values and
- * icaltime_adjust() to add or subtract days, hours, minutes & seconds.
+ * functions easier. New code should use ICalTimetype values and
+ * i_cal_time_adjust() to add or subtract days, hours, minutes & seconds.
  *
  * Returns: the beginning of the year.
  */
 time_t
 time_year_begin_with_zone (time_t time,
-                           icaltimezone *zone)
+                          const ICalTimezone *zone)
 {
-       struct icaltimetype tt;
+       ICalTimetype *tt;
+       time_t res;
 
        /* Convert to an icaltimetype. */
-       tt = icaltime_from_timet_with_zone (time, FALSE, zone);
+       tt = i_cal_time_from_timet_with_zone (time, FALSE, (ICalTimezone *) zone);
 
        /* Set it to the start of the year. */
-       tt.month = 1;
-       tt.day = 1;
-       tt.hour = 0;
-       tt.minute = 0;
-       tt.second = 0;
+       i_cal_timetype_set_month (tt, 1);
+       i_cal_timetype_set_day (tt, 1);
+       i_cal_timetype_set_hour (tt, 0);
+       i_cal_timetype_set_minute (tt, 0);
+       i_cal_timetype_set_second (tt, 0);
 
        /* Convert back to a time_t. */
-       return icaltime_as_timet_with_zone (tt, zone);
+       res = i_cal_time_as_timet_with_zone (tt, (ICalTimezone *) zone);
+
+       g_object_unref (tt);
+
+       return res;
 }
 
 /**
@@ -292,28 +308,33 @@ time_year_begin_with_zone (time_t time,
  * Returns the start of the month containing the given time_t, using the given
  * timezone.
  * NOTE: this function is only here to make the transition to the timezone
- * functions easier. New code should use icaltimetype values and
- * icaltime_adjust() to add or subtract days, hours, minutes & seconds.
+ * functions easier. New code should use ICalTimetype values and
+ * i_cal_time_adjust() to add or subtract days, hours, minutes & seconds.
  *
  * Returns: the beginning of the month.
  */
 time_t
 time_month_begin_with_zone (time_t time,
-                            icaltimezone *zone)
+                           const ICalTimezone *zone)
 {
-       struct icaltimetype tt;
+       ICalTimetype *tt;
+       time_t res;
 
        /* Convert to an icaltimetype. */
-       tt = icaltime_from_timet_with_zone (time, FALSE, zone);
+       tt = i_cal_time_from_timet_with_zone (time, FALSE, (ICalTimezone *) zone);
 
        /* Set it to the start of the month. */
-       tt.day = 1;
-       tt.hour = 0;
-       tt.minute = 0;
-       tt.second = 0;
+       i_cal_timetype_set_day (tt, 1);
+       i_cal_timetype_set_hour (tt, 0);
+       i_cal_timetype_set_minute (tt, 0);
+       i_cal_timetype_set_second (tt, 0);
 
        /* Convert back to a time_t. */
-       return icaltime_as_timet_with_zone (tt, zone);
+       res = i_cal_time_as_timet_with_zone (tt, (ICalTimezone *) zone);
+
+       g_object_unref (tt);
+
+       return res;
 }
 
 /**
@@ -326,39 +347,47 @@ time_month_begin_with_zone (time_t time,
  * timezone. week_start_day should use the same values as mktime(),
  * i.e. 0 (Sun) to 6 (Sat).
  * NOTE: this function is only here to make the transition to the timezone
- * functions easier. New code should use icaltimetype values and
- * icaltime_adjust() to add or subtract days, hours, minutes & seconds.
+ * functions easier. New code should use ICalTimetype values and
+ * i_cal_time_adjust() to add or subtract days, hours, minutes & seconds.
  *
  * Returns: the beginning of the week.
  */
 time_t
 time_week_begin_with_zone (time_t time,
-                           gint week_start_day,
-                           icaltimezone *zone)
+                          gint week_start_day,
+                          const ICalTimezone *zone)
 {
-       struct icaltimetype tt;
+       ICalTimetype *tt, *normtt;
        gint weekday, offset;
+       time_t res;
 
        /* Convert to an icaltimetype. */
-       tt = icaltime_from_timet_with_zone (time, FALSE, zone);
+       tt = i_cal_time_from_timet_with_zone (time, FALSE, (ICalTimezone *) zone);
 
        /* Get the weekday. */
-       weekday = time_day_of_week (tt.day, tt.month - 1, tt.year);
+       weekday = time_day_of_week (i_cal_timetype_get_day (tt), i_cal_timetype_get_month (tt) - 1, 
i_cal_timetype_get_year (tt));
 
        /* Calculate the current offset from the week start day. */
        offset = (weekday + 7 - week_start_day) % 7;
 
        /* Set it to the start of the month. */
-       tt.day -= offset;
-       tt.hour = 0;
-       tt.minute = 0;
-       tt.second = 0;
+       i_cal_timetype_set_day (tt, i_cal_timetype_get_day (tt) - offset);
+       i_cal_timetype_set_hour (tt, 0);
+       i_cal_timetype_set_minute (tt, 0);
+       i_cal_timetype_set_second (tt, 0);
 
        /* Normalize it, to fix any overflow. */
-       tt = icaltime_normalize (tt);
+       normtt = i_cal_time_normalize (tt);
+
+       g_object_unref (tt);
+       tt = normtt;
 
        /* Convert back to a time_t. */
-       return icaltime_as_timet_with_zone (tt, zone);
+       res = i_cal_time_as_timet_with_zone (tt, (ICalTimezone *) zone);
+
+       g_object_unref (tt);
+
+       return res;
 }
 
 /**
@@ -369,31 +398,33 @@ time_week_begin_with_zone (time_t time,
  * Returns the start of the day containing the given time_t, using the given
  * timezone.
  * NOTE: this function is only here to make the transition to the timezone
- * functions easier. New code should use icaltimetype values and
- * icaltime_adjust() to add or subtract days, hours, minutes & seconds.
+ * functions easier. New code should use ICalTimetype values and
+ * i_cal_time_adjust() to add or subtract days, hours, minutes & seconds.
  *
  * Returns: the beginning of the day.
  */
 time_t
 time_day_begin_with_zone (time_t time,
-                          icaltimezone *zone)
+                         const ICalTimezone *zone)
 {
-       struct icaltimetype tt;
+       ICalTimetype *tt;
        time_t new_time;
 
        /* Convert to an icaltimetype. */
-       tt = icaltime_from_timet_with_zone (time, FALSE, zone);
+       tt = i_cal_time_from_timet_with_zone (time, FALSE, (ICalTimezone *) zone);
 
        /* Set it to the start of the day. */
-       tt.hour = 0;
-       tt.minute = 0;
-       tt.second = 0;
+       i_cal_timetype_set_hour (tt, 0);
+       i_cal_timetype_set_minute (tt, 0);
+       i_cal_timetype_set_second (tt, 0);
 
        /* Convert back to a time_t and make sure the time is in the past. */
-       while (new_time = icaltime_as_timet_with_zone (tt, zone), new_time > time) {
-               icaltime_adjust (&tt, 0, -1, 0, 0);
+       while (new_time = i_cal_time_as_timet_with_zone (tt, (ICalTimezone *) zone), new_time > time) {
+               i_cal_time_adjust (tt, 0, -1, 0, 0);
        }
 
+       g_object_unref (tt);
+
        return new_time;
 }
 
@@ -405,33 +436,35 @@ time_day_begin_with_zone (time_t time,
  * Returns the end of the day containing the given time_t, using the given
  * timezone. (The end of the day is the start of the next day.)
  * NOTE: this function is only here to make the transition to the timezone
- * functions easier. New code should use icaltimetype values and
- * icaltime_adjust() to add or subtract days, hours, minutes & seconds.
+ * functions easier. New code should use ICalTimetype values and
+ * i_cal_time_adjust() to add or subtract days, hours, minutes & seconds.
  *
  * Returns: the end of the day.
  */
 time_t
 time_day_end_with_zone (time_t time,
-                        icaltimezone *zone)
+                       const ICalTimezone *zone)
 {
-       struct icaltimetype tt;
+       ICalTimetype *tt;
        time_t new_time;
 
        /* Convert to an icaltimetype. */
-       tt = icaltime_from_timet_with_zone (time, FALSE, zone);
+       tt = i_cal_time_from_timet_with_zone (time, FALSE, (ICalTimezone *) zone);
 
        /* Set it to the start of the next day. */
-       tt.hour = 0;
-       tt.minute = 0;
-       tt.second = 0;
+       i_cal_timetype_set_hour (tt, 0);
+       i_cal_timetype_set_minute (tt, 0);
+       i_cal_timetype_set_second (tt, 0);
 
-       icaltime_adjust (&tt, 1, 0, 0, 0);
+       i_cal_time_adjust (tt, 1, 0, 0, 0);
 
        /* Convert back to a time_t and make sure the time is in the future. */
-       while (new_time = icaltime_as_timet_with_zone (tt, zone), new_time <= time) {
-               icaltime_adjust (&tt, 0, 1, 0, 0);
+       while (new_time = i_cal_time_as_timet_with_zone (tt, (ICalTimezone *) zone), new_time <= time) {
+               i_cal_time_adjust (tt, 0, 1, 0, 0);
        }
 
+       g_object_unref (tt);
+
        return new_time;
 }
 
@@ -439,27 +472,29 @@ time_day_end_with_zone (time_t time,
  * time_to_gdate_with_zone:
  * @date: Destination #GDate value.
  * @time: A time value.
- * @zone: Desired timezone for destination @date, or NULL if the UTC timezone
- * is desired.
+ * @zone: (nullable): Desired timezone for destination @date, or %NULL if
+ *    the UTC timezone is desired.
  *
  * Converts a time_t value to a #GDate structure using the specified timezone.
  * This is analogous to g_date_set_time() but takes the timezone into account.
  **/
 void
 time_to_gdate_with_zone (GDate *date,
-                         time_t time,
-                         icaltimezone *zone)
+                        time_t time,
+                        const ICalTimezone *zone)
 {
-       struct icaltimetype tt;
+       ICalTimetype *tt;
 
        g_return_if_fail (date != NULL);
        g_return_if_fail (time != -1);
 
-       tt = icaltime_from_timet_with_zone (
+       tt = i_cal_time_from_timet_with_zone (
                time, FALSE,
-               zone ? zone : icaltimezone_get_utc_timezone ());
+               zone ? (ICalTimezone *) zone : i_cal_timezone_get_utc_timezone ());
+
+       g_date_set_dmy (date, i_cal_timetype_get_day (tt), i_cal_timetype_get_month (tt), 
i_cal_timetype_get_year (tt));
 
-       g_date_set_dmy (date, tt.day, tt.month, tt.year);
+       g_object_unref (tt);
 }
 
 /**************************************************************************
@@ -630,9 +665,10 @@ isodate_from_time_t (time_t t)
 time_t
 time_from_isodate (const gchar *str)
 {
-       struct icaltimetype tt = icaltime_null_time ();
-       icaltimezone *utc_zone;
+       ICalTimetype *tt;
+       ICalTimezone *utc_zone;
        gint len, i;
+       time_t res;
 
        g_return_val_if_fail (str != NULL, -1);
 
@@ -651,59 +687,68 @@ time_from_isodate (const gchar *str)
 
 #define digit_at(x,y) (x[y] - '0')
 
-       tt.year = digit_at (str, 0) * 1000
-               + digit_at (str, 1) * 100
-               + digit_at (str, 2) * 10
-               + digit_at (str, 3);
+       tt = i_cal_time_null_time ();
 
-       tt.month = digit_at (str, 4) * 10
-                + digit_at (str, 5);
+       i_cal_timetype_set_year (tt, digit_at (str, 0) * 1000 +
+                                    digit_at (str, 1) * 100 +
+                                    digit_at (str, 2) * 10 +
+                                    digit_at (str, 3));
 
-       tt.day = digit_at (str, 6) * 10
-              + digit_at (str, 7);
+       i_cal_timetype_set_month (tt, digit_at (str, 4) * 10 +
+                                     digit_at (str, 5));
+
+       i_cal_timetype_set_day (tt, digit_at (str, 6) * 10 +
+                                   digit_at (str, 7));
 
        if (len > 8) {
-               tt.hour = digit_at (str, 9) * 10
-                       + digit_at (str, 10);
-               tt.minute = digit_at (str, 11) * 10
-                          + digit_at (str, 12);
-               tt.second = digit_at (str, 13) * 10
-                          + digit_at (str, 14);
+               i_cal_timetype_set_hour (tt, digit_at (str, 9) * 10 +
+                                            digit_at (str, 10));
+               i_cal_timetype_set_minute (tt, digit_at (str, 11) * 10 +
+                                              digit_at (str, 12));
+               i_cal_timetype_set_second (tt, digit_at (str, 13) * 10 +
+                                              digit_at (str, 14));
        }
 
-       utc_zone = icaltimezone_get_utc_timezone ();
+       utc_zone = i_cal_timezone_get_utc_timezone ();
+
+       res = i_cal_time_as_timet_with_zone (tt, utc_zone);
 
-       return icaltime_as_timet_with_zone (tt, utc_zone);
+       g_object_unref (tt);
+
+       return res;
 }
 
 /**
  * icaltimetype_to_tm:
- * @itt: An icaltimetype structure.
+ * @itt: An #ICalTimetype
  *
- * Convers an icaltimetype structure into a GLibc's struct tm.
+ * Converts an #ICalTimetype into a GLibc's struct tm.
  *
- * Returns: (transfer full): The converted time as a struct tm. All fields will be
- * set properly except for tm.tm_yday.
+ * Returns: The converted time as a struct tm. All fields will be
+ *    set properly except for tm.tm_yday.
  *
  * Since: 2.22
  */
 struct tm
-icaltimetype_to_tm (struct icaltimetype *itt)
+icaltimetype_to_tm (const ICalTimetype *itt)
 {
        struct tm tm;
+       ICalTimetype *tt = (ICalTimetype *) itt;
 
        memset (&tm, 0, sizeof (struct tm));
 
-       if (!itt->is_date) {
-               tm.tm_sec = itt->second;
-               tm.tm_min = itt->minute;
-               tm.tm_hour = itt->hour;
+       g_return_val_if_fail (itt != NULL, tm);
+
+       if (!i_cal_timetype_get_is_date (tt)) {
+               tm.tm_sec = i_cal_timetype_get_second (tt);
+               tm.tm_min = i_cal_timetype_get_minute (tt);
+               tm.tm_hour = i_cal_timetype_get_hour (tt);
        }
 
-       tm.tm_mday = itt->day;
-       tm.tm_mon = itt->month - 1;
-       tm.tm_year = itt->year - 1900;
-       tm.tm_wday = time_day_of_week (itt->day, itt->month - 1, itt->year);
+       tm.tm_mday = i_cal_timetype_get_day (tt);
+       tm.tm_mon = i_cal_timetype_get_month (tt) - 1;
+       tm.tm_year = i_cal_timetype_get_year (tt) - 1900;
+       tm.tm_wday = time_day_of_week (i_cal_timetype_get_day (tt), i_cal_timetype_get_month (tt) - 1, 
i_cal_timetype_get_year (tt));
        tm.tm_isdst = -1;
 
        return tm;
@@ -718,28 +763,29 @@ icaltimetype_to_tm (struct icaltimetype *itt)
  * Converts a time value from one timezone to another, and returns a struct tm
  * representation of the time.
  *
- * Returns: (transfer full): The converted time as a struct tm. All fields will be
- * set properly except for tm.tm_yday.
+ * Returns: The converted time as a struct tm. All fields will be
+ *    set properly except for tm.tm_yday.
  *
  * Since: 2.22
  **/
 struct tm
-icaltimetype_to_tm_with_zone (struct icaltimetype *itt,
-                              icaltimezone *from_zone,
-                              icaltimezone *to_zone)
+icaltimetype_to_tm_with_zone (const ICalTimetype *itt,
+                             const ICalTimezone *from_zone,
+                             const ICalTimezone *to_zone)
 {
        struct tm tm;
-       struct icaltimetype itt_copy;
+       ICalTimetype *itt_copy;
 
        memset (&tm, 0, sizeof (tm));
        tm.tm_isdst = -1;
 
        g_return_val_if_fail (itt != NULL, tm);
 
-       itt_copy = *itt;
+       itt_copy = i_cal_timetype_new_clone (itt);
 
-       icaltimezone_convert_time (&itt_copy, from_zone, to_zone);
-       tm = icaltimetype_to_tm (&itt_copy);
+       i_cal_timezone_convert_time (itt_copy, (ICalTimezone *) from_zone, (ICalTimezone *) to_zone);
+       tm = icaltimetype_to_tm (itt_copy);
+       g_object_unref (itt_copy);
 
        return tm;
 }
@@ -749,32 +795,28 @@ icaltimetype_to_tm_with_zone (struct icaltimetype *itt,
  * @tm: A struct tm.
  * @is_date: Whether the given time is a date only or not.
  *
- * Converts a struct tm into an icaltimetype.
+ * Converts a struct tm into an #ICalTimetype. Free the returned object
+ * with g_object_unref(), when no longe needed.
  *
- * Returns: (transfer full): The converted time as an icaltimetype.
+ * Returns: (transfer full): The converted time as an #ICalTimetype.
  *
  * Since: 2.22
  */
-struct icaltimetype
+ICalTimetype *
 tm_to_icaltimetype (struct tm *tm,
                     gboolean is_date)
 {
-       struct icaltimetype itt;
+       ICalTimetype *itt;
 
-       memset (&itt, 0, sizeof (struct icaltimetype));
+       g_return_val_if_fail (tm != NULL, NULL);
 
-       if (!is_date) {
-               itt.second = tm->tm_sec;
-               itt.minute = tm->tm_min;
-               itt.hour = tm->tm_hour;
-       }
+       itt = i_cal_time_null_time ();
 
-       itt.day = tm->tm_mday;
-       itt.month = tm->tm_mon + 1;
-       itt.year = tm->tm_year + 1900;
+       if (!is_date)
+               i_cal_timetype_set_time (itt, tm->tm_hour, tm->tm_min, tm->tm_sec);
 
-       itt.is_date = is_date;
+       i_cal_timetype_set_date (itt, tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday);
+       i_cal_timetype_set_is_date (itt, is_date);
 
        return itt;
 }
-
diff --git a/src/calendar/libecal/e-cal-time-util.h b/src/calendar/libecal/e-cal-time-util.h
index df665226f..37f93180d 100644
--- a/src/calendar/libecal/e-cal-time-util.h
+++ b/src/calendar/libecal/e-cal-time-util.h
@@ -39,99 +39,124 @@ G_BEGIN_DECLS
 
 /* Returns the number of days in the month. Year is the normal year, e.g. 2001.
  * Month is 0 (Jan) to 11 (Dec). */
-gint   time_days_in_month      (gint year, gint month);
+gint           time_days_in_month      (gint year,
+                                        gint month);
 
 /* Returns the 1-based day number within the year of the specified date.
  * Year is the normal year, e.g. 2001. Month is 0 to 11. */
-gint   time_day_of_year        (gint day, gint month, gint year);
+gint           time_day_of_year        (gint day,
+                                        gint month,
+                                        gint year);
 
 /* Returns the day of the week for the specified date, 0 (Sun) to 6 (Sat).
  * For the days that were removed on the Gregorian reformation, it returns
  * Thursday. Year is the normal year, e.g. 2001. Month is 0 to 11. */
-gint   time_day_of_week        (gint day, gint month, gint year);
+gint           time_day_of_week        (gint day,
+                                        gint month,
+                                        gint year);
 
 /* Returns whether the specified year is a leap year. Year is the normal year,
  * e.g. 2001. */
-gboolean time_is_leap_year     (gint year);
+gboolean       time_is_leap_year       (gint year);
 
 /* Returns the number of leap years since year 1 up to (but not including) the
  * specified year. Year is the normal year, e.g. 2001. */
-gint   time_leap_years_up_to   (gint year);
+gint           time_leap_years_up_to   (gint year);
 
 /* Convert to or from an ISO 8601 representation of a time, in UTC,
  * e.g. "20010708T183000Z". */
-gchar   *isodate_from_time_t     (time_t t);
-time_t time_from_isodate       (const gchar *str);
+gchar *                isodate_from_time_t     (time_t t);
+time_t         time_from_isodate       (const gchar *str);
 
 /**************************************************************************
  * time_t manipulation functions.
  *
  * NOTE: these use the Unix timezone functions like mktime() and localtime()
  * and so should not be used in Evolution. New Evolution code should use
- * icaltimetype values rather than time_t values wherever possible.
+ * ICalTimetype values rather than time_t values wherever possible.
  **************************************************************************/
 
 /* Add or subtract a number of days, weeks or months. */
-time_t time_add_day            (time_t time, gint days);
-time_t time_add_week           (time_t time, gint weeks);
+time_t         time_add_day            (time_t time,
+                                        gint days);
+time_t         time_add_week           (time_t time,
+                                        gint weeks);
 
 /* Returns the beginning or end of the day. */
-time_t time_day_begin          (time_t t);
-time_t time_day_end            (time_t t);
+time_t         time_day_begin          (time_t t);
+time_t         time_day_end            (time_t t);
 
 /**************************************************************************
  * time_t manipulation functions, using timezones in libical.
  *
  * NOTE: these are only here to make the transition to the timezone
- * functions easier. New code should use icaltimetype values rather than
+ * functions easier. New code should use ICalTimetype values rather than
  * time_t values wherever possible.
  **************************************************************************/
 
 /* Adds or subtracts a number of days to/from the given time_t value, using
  * the given timezone. */
-time_t time_add_day_with_zone (time_t time, gint days, icaltimezone *zone);
+time_t         time_add_day_with_zone  (time_t time,
+                                        gint days,
+                                        const ICalTimezone *zone);
 
 /* Adds or subtracts a number of weeks to/from the given time_t value, using
  * the given timezone. */
-time_t time_add_week_with_zone (time_t time, gint weeks, icaltimezone *zone);
+time_t         time_add_week_with_zone (time_t time,
+                                        gint weeks,
+                                        const ICalTimezone *zone);
 
 /* Adds or subtracts a number of months to/from the given time_t value, using
  * the given timezone. */
-time_t time_add_month_with_zone (time_t time, gint months, icaltimezone *zone);
+time_t         time_add_month_with_zone(time_t time,
+                                        gint months,
+                                        const ICalTimezone *zone);
 
 /* Returns the start of the year containing the given time_t, using the given
  * timezone. */
-time_t time_year_begin_with_zone (time_t time, icaltimezone *zone);
+time_t         time_year_begin_with_zone
+                                       (time_t time,
+                                        const ICalTimezone *zone);
 
 /* Returns the start of the month containing the given time_t, using the given
  * timezone. */
-time_t time_month_begin_with_zone (time_t time, icaltimezone *zone);
+time_t         time_month_begin_with_zone
+                                       (time_t time,
+                                        const ICalTimezone *zone);
 
 /* Returns the start of the week containing the given time_t, using the given
  * timezone. week_start_day should use the same values as mktime (),
  * i.e. 0 (Sun) to 6 (Sat). */
-time_t time_week_begin_with_zone (time_t time, gint week_start_day,
-                                  icaltimezone *zone);
+time_t         time_week_begin_with_zone
+                                       (time_t time,
+                                        gint week_start_day,
+                                        const ICalTimezone *zone);
 
 /* Returns the start of the day containing the given time_t, using the given
  * timezone. */
-time_t time_day_begin_with_zone (time_t time, icaltimezone *zone);
+time_t         time_day_begin_with_zone(time_t time,
+                                        const ICalTimezone *zone);
 
 /* Returns the end of the day containing the given time_t, using the given
  * timezone. (The end of the day is the start of the next day.) */
-time_t time_day_end_with_zone (time_t time, icaltimezone *zone);
+time_t         time_day_end_with_zone  (time_t time,
+                                        const ICalTimezone *zone);
 
-void time_to_gdate_with_zone (GDate *date, time_t time, icaltimezone *zone);
+void           time_to_gdate_with_zone (GDate *date,
+                                        time_t time,
+                                        const ICalTimezone *zone);
 
 /**************************************************************************
  * struct tm manipulation
  **************************************************************************/
 
-struct tm icaltimetype_to_tm (struct icaltimetype *itt);
-struct tm icaltimetype_to_tm_with_zone (struct icaltimetype *itt,
-                                       icaltimezone *from_zone,
-                                       icaltimezone *to_zone);
-struct icaltimetype tm_to_icaltimetype (struct tm *tm, gboolean is_date);
+struct tm      icaltimetype_to_tm      (const ICalTimetype *itt);
+struct tm      icaltimetype_to_tm_with_zone
+                                       (const ICalTimetype *itt,
+                                        const ICalTimezone *from_zone,
+                                        const ICalTimezone *to_zone);
+ICalTimetype * tm_to_icaltimetype      (struct tm *tm,
+                                        gboolean is_date);
 
 G_END_DECLS
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]