aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--libical/ChangeLog7
-rw-r--r--libical/src/libical/icaltime.c14
-rw-r--r--libical/src/libical/icaltimezone.c13
3 files changed, 32 insertions, 2 deletions
diff --git a/libical/ChangeLog b/libical/ChangeLog
index 06db567a0e..bae7663efa 100644
--- a/libical/ChangeLog
+++ b/libical/ChangeLog
@@ -1,3 +1,10 @@
+2001-07-09 Damon Chaplin <damon@ximian.com>
+
+ * src/libical/icaltimezone.c (icaltimezone_convert_time): if the 2
+ zones are the same just return.
+
+ * src/libical/icaltime.c (icaltime_adjust): normalize the month.
+
2001-07-03 Damon Chaplin <damon@ximian.com>
* src/libical/icalcomponent.c (icalcomponent_add_component): add the
diff --git a/libical/src/libical/icaltime.c b/libical/src/libical/icaltime.c
index 6f6ed5748f..e3229c6925 100644
--- a/libical/src/libical/icaltime.c
+++ b/libical/src/libical/icaltime.c
@@ -617,6 +617,20 @@ icaltime_adjust (struct icaltimetype *tt,
days_overflow--;
}
+ /* Normalize the month. We do this before handling the day since we may
+ need to know what month it is to get the number of days in it.
+ Note that months are 1 to 12, so we have to be a bit careful. */
+ if (tt->month >= 13) {
+ years_overflow = (month - 1) / 12;
+ tt->year += years_overflow;
+ tt->month -= years_overflow * 12;
+ } else if (tt->month <= 0) {
+ /* 0 to -11 is -1 year out, -12 to -23 is -2 years. */
+ years_overflow = (month / 12) - 1;
+ tt->year += years_overflow;
+ tt->month -= years_overflow * 12;
+ }
+
/* Add on the days. */
day = tt->day + days + days_overflow;
if (day > 0) {
diff --git a/libical/src/libical/icaltimezone.c b/libical/src/libical/icaltimezone.c
index def5c1a6fc..5ad77e4171 100644
--- a/libical/src/libical/icaltimezone.c
+++ b/libical/src/libical/icaltimezone.c
@@ -255,15 +255,21 @@ icaltimezone_get_vtimezone_properties (icaltimezone *zone,
icalproperty *prop;
const char *tzid, *location;
+ fprintf (stderr, "In icaltimezone_get_vtimezone_properties\n");
+
prop = icalcomponent_get_first_property (component, ICAL_TZID_PROPERTY);
if (!prop)
return 0;
+ fprintf (stderr, " found TZID property, getting TZID\n");
+
/* A VTIMEZONE MUST have a TZID, or a lot of our code won't work. */
tzid = icalproperty_get_tzid (prop);
if (!tzid)
return 0;
+ fprintf (stderr, " found TZID: %s\n", tzid);
+
zone->tzid = strdup (tzid);
zone->component = component;
zone->location = icaltimezone_get_location_from_vtimezone (component);
@@ -721,8 +727,11 @@ icaltimezone_convert_time (struct icaltimetype *tt,
{
int utc_offset, is_daylight;
- /* First we convert the time to UTC by getting the UTC offset and
- subtracting it. */
+ /* If both timezones are the same, we don't need to do anything. */
+ if (from_zone == to_zone)
+ return;
+
+ /* Convert the time to UTC by getting the UTC offset and subtracting it. */
utc_offset = icaltimezone_get_utc_offset (from_zone, tt, NULL);
icaltime_adjust (tt, 0, 0, 0, -utc_offset);