aboutsummaryrefslogtreecommitdiffstats
path: root/calendar/cal-util
diff options
context:
space:
mode:
authorFederico Mena Quintero <federico@helixcode.com>2000-12-20 02:12:57 +0800
committerFederico Mena Quintero <federico@src.gnome.org>2000-12-20 02:12:57 +0800
commitde861766eded0c80ffbe050088043a16d7e4923f (patch)
tree5010fda36af306efaab59e11ebfa12b7bd43023a /calendar/cal-util
parent20dabfff3014eb67b5c930345e8cb64116dba374 (diff)
downloadgsoc2013-evolution-de861766eded0c80ffbe050088043a16d7e4923f.tar
gsoc2013-evolution-de861766eded0c80ffbe050088043a16d7e4923f.tar.gz
gsoc2013-evolution-de861766eded0c80ffbe050088043a16d7e4923f.tar.bz2
gsoc2013-evolution-de861766eded0c80ffbe050088043a16d7e4923f.tar.lz
gsoc2013-evolution-de861766eded0c80ffbe050088043a16d7e4923f.tar.xz
gsoc2013-evolution-de861766eded0c80ffbe050088043a16d7e4923f.tar.zst
gsoc2013-evolution-de861766eded0c80ffbe050088043a16d7e4923f.zip
Fix confusion in the way the range is expanded.
2000-12-19 Federico Mena Quintero <federico@helixcode.com> * pcs/cal-backend-file.c (compute_alarm_range): Fix confusion in the way the range is expanded. * cal-util/cal-component.c (cal_component_alarms_free): Doh, alarms->alarms is a list, not a generic pointer. Free it properly. (cal_component_free_pilot_id): Removed unused function. (cal_component_free_pilot_status): Likewise. * gui/main.c (init_bonobo): Use VERSION instead of a hardcoded string. Pass argc by value, not by reference. Test the return value of gnome_init_with_popt_table(). * cal-client/cal-client.c (cal_client_free_alarms): Oops, missed implementing this function. * cal-util/timeutil.c (print_time_t): Better printing format. (isodiff_to_secs): Removed unused function. (isodiff_from_secs): Removed unused function. (time_day_end): Removed crufty part. (time_day_begin): Removed crufty part. (time_day_hour): Removed unused function. (format_simple_hour): Removed unused function. (get_time_t_hour): Removed unused function. (time_from_start_duration): Removed unused function. * cal-util/timeutil.h (parse_date): Removed unimplemented, unused function prototype. svn path=/trunk/; revision=7083
Diffstat (limited to 'calendar/cal-util')
-rw-r--r--calendar/cal-util/cal-component.c170
-rw-r--r--calendar/cal-util/cal-component.h8
-rw-r--r--calendar/cal-util/timeutil.c240
-rw-r--r--calendar/cal-util/timeutil.h13
4 files changed, 86 insertions, 345 deletions
diff --git a/calendar/cal-util/cal-component.c b/calendar/cal-util/cal-component.c
index 1ece361da7..0c7ca50d9f 100644
--- a/calendar/cal-util/cal-component.c
+++ b/calendar/cal-util/cal-component.c
@@ -1130,73 +1130,6 @@ cal_component_set_uid (CalComponent *comp, const char *uid)
}
/**
- * cal_component_get_status:
- * @comp: A calendar component object.
- * @status: Return value for the status value. It is set to #ICAL_STATUS_NONE
- * if the component has no status property.
- *
- * Queries the status property of a calendar component object.
- **/
-void
-cal_component_get_status (CalComponent *comp, icalproperty_status *status)
-{
- CalComponentPrivate *priv;
-
- g_return_if_fail (comp != NULL);
- g_return_if_fail (IS_CAL_COMPONENT (comp));
- g_return_if_fail (status != NULL);
-
- priv = comp->priv;
- g_return_if_fail (priv->icalcomp != NULL);
-
- if (!priv->status) {
- *status = ICAL_STATUS_NONE;
- return;
- }
-
- *status = icalproperty_get_status (priv->status);
-}
-
-/**
- * cal_component_set_status:
- * @comp: A calendar component object.
- * @status: Status value. You should use #ICAL_STATUS_NONE if you want to unset
- * this property.
- *
- * Sets the status property of a calendar component object.
- **/
-void
-cal_component_set_status (CalComponent *comp, icalproperty_status status)
-{
- CalComponentPrivate *priv;
-
- g_return_if_fail (comp != NULL);
- g_return_if_fail (IS_CAL_COMPONENT (comp));
-
- priv = comp->priv;
- g_return_if_fail (priv->icalcomp != NULL);
-
- priv->need_sequence_inc = TRUE;
-
- if (status == ICAL_STATUS_NONE) {
- if (priv->status) {
- icalcomponent_remove_property (priv->icalcomp, priv->status);
- icalproperty_free (priv->status);
- priv->status = NULL;
- }
-
- return;
- }
-
- if (priv->status) {
- icalproperty_set_status (priv->status, status);
- } else {
- priv->status = icalproperty_new_status (status);
- icalcomponent_add_property (priv->icalcomp, priv->status);
- }
-}
-
-/**
* cal_component_get_categories_list:
* @comp: A calendar component object.
* @categ_list: Return value for the list of strings, where each string is a
@@ -2381,8 +2314,7 @@ cal_component_get_exrule_list (CalComponent *comp, GSList **recur_list)
* @comp: A calendar component object.
* @recur_list: Returns a list of exception rule properties.
*
- * Returns a list of exception rule properties of a calendar component
- * object.
+ * Queries the list of exception rule properties of a calendar component object.
**/
void
cal_component_get_exrule_property_list (CalComponent *comp, GSList **recur_list)
@@ -2802,8 +2734,7 @@ cal_component_get_rrule_list (CalComponent *comp, GSList **recur_list)
* @comp: A calendar component object.
* @recur_list: Returns a list of recurrence rule properties.
*
- * Returns a list of recurrence rule properties of a calendar component
- * object.
+ * Queries a list of recurrence rule properties of a calendar component object.
**/
void
cal_component_get_rrule_property_list (CalComponent *comp, GSList **recur_list)
@@ -2951,6 +2882,73 @@ cal_component_set_sequence (CalComponent *comp, int *sequence)
}
/**
+ * cal_component_get_status:
+ * @comp: A calendar component object.
+ * @status: Return value for the status value. It is set to #ICAL_STATUS_NONE
+ * if the component has no status property.
+ *
+ * Queries the status property of a calendar component object.
+ **/
+void
+cal_component_get_status (CalComponent *comp, icalproperty_status *status)
+{
+ CalComponentPrivate *priv;
+
+ g_return_if_fail (comp != NULL);
+ g_return_if_fail (IS_CAL_COMPONENT (comp));
+ g_return_if_fail (status != NULL);
+
+ priv = comp->priv;
+ g_return_if_fail (priv->icalcomp != NULL);
+
+ if (!priv->status) {
+ *status = ICAL_STATUS_NONE;
+ return;
+ }
+
+ *status = icalproperty_get_status (priv->status);
+}
+
+/**
+ * cal_component_set_status:
+ * @comp: A calendar component object.
+ * @status: Status value. You should use #ICAL_STATUS_NONE if you want to unset
+ * this property.
+ *
+ * Sets the status property of a calendar component object.
+ **/
+void
+cal_component_set_status (CalComponent *comp, icalproperty_status status)
+{
+ CalComponentPrivate *priv;
+
+ g_return_if_fail (comp != NULL);
+ g_return_if_fail (IS_CAL_COMPONENT (comp));
+
+ priv = comp->priv;
+ g_return_if_fail (priv->icalcomp != NULL);
+
+ priv->need_sequence_inc = TRUE;
+
+ if (status == ICAL_STATUS_NONE) {
+ if (priv->status) {
+ icalcomponent_remove_property (priv->icalcomp, priv->status);
+ icalproperty_free (priv->status);
+ priv->status = NULL;
+ }
+
+ return;
+ }
+
+ if (priv->status) {
+ icalproperty_set_status (priv->status, status);
+ } else {
+ priv->status = icalproperty_new_status (status);
+ icalcomponent_add_property (priv->icalcomp, priv->status);
+ }
+}
+
+/**
* cal_component_get_summary:
* @comp: A calendar component object.
* @summary: Return value for the summary property and its parameters.
@@ -3369,34 +3367,6 @@ cal_component_free_sequence (int *sequence)
}
/**
- * cal_component_free_pilot_id:
- * @sequence: Sequence number value.
- *
- * Frees a sequence number value.
- **/
-void
-cal_component_free_pilot_id (unsigned long *pilot_id)
-{
- g_return_if_fail (pilot_id != NULL);
-
- g_free (pilot_id);
-}
-
-/**
- * cal_component_free_pilot_status:
- * @sequence: Sequence number value.
- *
- * Frees a sequence number value.
- **/
-void
-cal_component_free_pilot_status (unsigned long *pilot_status)
-{
- g_return_if_fail (pilot_status != NULL);
-
- g_free (pilot_status);
-}
-
-/**
* cal_component_free_text_list:
* @text_list: List of #CalComponentText structures.
*
@@ -3625,7 +3595,7 @@ cal_component_alarms_free (CalComponentAlarms *alarms)
g_free (instance);
}
- g_free (alarms->alarms);
+ g_slist_free (alarms->alarms);
g_free (alarms);
}
diff --git a/calendar/cal-util/cal-component.h b/calendar/cal-util/cal-component.h
index 893e066f52..5d649fb7ca 100644
--- a/calendar/cal-util/cal-component.h
+++ b/calendar/cal-util/cal-component.h
@@ -173,9 +173,6 @@ void cal_component_commit_sequence (CalComponent *comp);
void cal_component_get_uid (CalComponent *comp, const char **uid);
void cal_component_set_uid (CalComponent *comp, const char *uid);
-void cal_component_get_status (CalComponent *comp, icalproperty_status *status);
-void cal_component_set_status (CalComponent *comp, icalproperty_status status);
-
void cal_component_get_categories_list (CalComponent *comp, GSList **categ_list);
void cal_component_set_categories_list (CalComponent *comp, GSList *categ_list);
@@ -243,6 +240,9 @@ gboolean cal_component_has_recurrences (CalComponent *comp);
void cal_component_get_sequence (CalComponent *comp, int **sequence);
void cal_component_set_sequence (CalComponent *comp, int *sequence);
+void cal_component_get_status (CalComponent *comp, icalproperty_status *status);
+void cal_component_set_status (CalComponent *comp, icalproperty_status status);
+
void cal_component_get_summary (CalComponent *comp, CalComponentText *summary);
void cal_component_set_summary (CalComponent *comp, CalComponentText *summary);
@@ -264,8 +264,6 @@ void cal_component_free_priority (int *priority);
void cal_component_free_period_list (GSList *period_list);
void cal_component_free_recur_list (GSList *recur_list);
void cal_component_free_sequence (int *sequence);
-void cal_component_free_pilot_id (unsigned long *pilot_status);
-void cal_component_free_pilot_status (unsigned long *pilot_status);
void cal_component_free_text_list (GSList *text_list);
/* Alarms */
diff --git a/calendar/cal-util/timeutil.c b/calendar/cal-util/timeutil.c
index 933230872b..6bc893831d 100644
--- a/calendar/cal-util/timeutil.c
+++ b/calendar/cal-util/timeutil.c
@@ -17,20 +17,11 @@ print_time_t (time_t t)
{
struct tm *tm = localtime (&t);
- printf ("TIEMPO: %d/%d/%d %d:%d:%d\n",
- tm->tm_mon+1, tm->tm_mday, tm->tm_year,
+ 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);
}
-int
-get_time_t_hour (time_t t)
-{
- struct tm *tm;
-
- tm = localtime (&t);
- return tm->tm_hour;
-}
-
char *
isodate_from_time_t (time_t t)
{
@@ -43,43 +34,17 @@ isodate_from_time_t (time_t t)
}
time_t
-time_from_start_duration (time_t start, char *duration)
-{
- printf ("Not yet implemented\n");
- return 0;
-}
-
-char *
-format_simple_hour (int hour, int use_am_pm)
-{
- static char buf[256];
-
- /* I don't know whether this is the best way to internationalize it.
- * Does any language use different conventions? - Federico
- */
-
- if (use_am_pm)
- g_snprintf (buf, sizeof(buf), "%d%s",
- (hour == 0) ? 12 : (hour > 12) ? (hour - 12) : hour,
- (hour < 12) ? _("am") : _("pm"));
- else
- g_snprintf (buf, sizeof(buf), "%02d%s", hour, _("h"));
-
- return buf;
-
-}
-
-time_t
time_add_minutes (time_t time, int minutes)
{
struct tm *tm = localtime (&time);
time_t new_time;
tm->tm_min += minutes;
- if ((new_time = mktime (tm)) == -1){
+ if ((new_time = mktime (tm)) == -1) {
g_message ("time_add_minutes(): mktime() could not handle "
"adding %d minutes with\n", minutes);
print_time_t (time);
+ printf ("\n");
return time;
}
return new_time;
@@ -104,20 +69,21 @@ time_add_day (time_t time, int days)
tm->tm_mday += days;
tm->tm_isdst = -1;
- if ((new_time = mktime (tm)) == -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;
}
#if 0
/* I don't know what this is for. See also time_day_begin() and
time_day_end(). - Damon. */
- if (dst_flag > tm->tm_isdst){
+ if (dst_flag > tm->tm_isdst) {
tm->tm_hour++;
new_time += 3600;
- } else if (dst_flag < tm->tm_isdst){
+ } else if (dst_flag < tm->tm_isdst) {
tm->tm_hour--;
new_time -= 3600;
}
@@ -143,14 +109,15 @@ time_add_month (time_t time, int months)
tm->tm_mon += months;
tm->tm_isdst = -1;
- if ((new_time = mktime (tm)) == -1){
+ if ((new_time = mktime (tm)) == -1) {
g_message ("time_add_month(): mktime() could not handling adding %d months with\n",
months);
print_time_t (time);
+ printf ("\n");
return time;
}
tm = localtime (&new_time);
- if (tm->tm_mday < mday){
+ if (tm->tm_mday < mday) {
tm->tm_mon--;
tm->tm_mday = time_days_in_month (tm->tm_year+1900, tm->tm_mon);
return new_time = mktime (tm);
@@ -166,28 +133,16 @@ time_add_year (time_t time, int years)
time_t new_time;
tm->tm_year += years;
- if ((new_time = mktime (tm)) == -1){
+ if ((new_time = mktime (tm)) == -1) {
g_message ("time_add_year(): mktime() could not handling adding %d years with\n",
years);
print_time_t (time);
+ printf ("\n");
return time;
}
return new_time;
}
-time_t
-time_day_hour (time_t t, int hour)
-{
- struct tm tm;
-
- tm = *localtime (&t);
- tm.tm_hour = hour;
- tm.tm_min = 0;
- tm.tm_sec = 0;
-
- return mktime (&tm);
-}
-
/* Number of days in a month, for normal and leap years */
static const int days_in_month[2][12] = {
{ 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 },
@@ -329,7 +284,6 @@ time_week_end (time_t t)
time_t
time_day_begin (time_t t)
{
-#if 1
struct tm tm;
tm = *localtime (&t);
@@ -339,44 +293,12 @@ time_day_begin (time_t t)
tm.tm_isdst = -1;
return mktime (&tm);
-
-#else
- /* This is the original code which sometimes produces a time of 1:00.
- I don't understand why it looked at the tm_isdst flags at all.
- - Damon. */
-
- struct tm tm;
- time_t temp = t - 43200;
- int dstflag, dstflag2;
-
- tm = *localtime(&temp); /* one day */
- dstflag = tm.tm_isdst;
-
- tm = *localtime (&t);
- dstflag2 = tm.tm_isdst;
-
- if (dstflag < dstflag2)
- tm.tm_hour = 1;
- else
- tm.tm_hour = 0;
-
- tm.tm_min = 0;
- tm.tm_sec = 0;
-
- temp = mktime(&tm);
- if (dstflag > dstflag2){
- temp += 3600;
- }
-
- return temp;
-#endif
}
/* Returns the end of the day, according to the local time. */
time_t
time_day_end (time_t t)
{
-#if 1
struct tm tm;
tm = *localtime (&t);
@@ -387,140 +309,4 @@ time_day_end (time_t t)
tm.tm_isdst = -1;
return mktime (&tm);
-
-#else
- /* This is the original code which has more problems than
- time_day_begin(). - Damon. */
-
- struct tm tm;
- time_t temp;
- int dstflag, dstflag2;
-
- t += 10800;
- temp = t - 86400;
-
- tm = *localtime(&temp); /* one day */
- dstflag = tm.tm_isdst;
-
- tm = *localtime (&t);
- dstflag2 = tm.tm_isdst;
-
- if (dstflag < dstflag2)
- tm.tm_hour = 23;
- else {
- tm.tm_mday++;
- tm.tm_hour = 0;
- }
- tm.tm_min = 0;
- tm.tm_sec = 0;
-
- temp = mktime(&tm);
- if(dstflag > dstflag2) {
- }
- return temp;
-#endif
-}
-
-static char *
-pcat (char *dest, int num, char key)
-{
- int c;
-
- c = sprintf (dest, "%d%c", num, key);
- return dest + c;
-}
-
-/* Converts secs into the ISO difftime representation */
-char *
-isodiff_from_secs (int secs)
-{
- static char buffer [60], *p;
- int years, months, weeks, days, hours, minutes;
-
- years = months = weeks = days = hours = minutes = 0;
-
- years = secs / (365 * 86400);
- secs %= (365 * 86400);
- months = secs / (30 * 86400);
- secs %= (30 * 86400);
- weeks = secs / (7 * 86400);
- secs %= (7 * 86400);
- days = secs / 86400;
- secs %= 86400;
- hours = secs / 3600;
- secs %= 3600;
- minutes = secs / 60;
- secs %= 60;
-
- strcpy (buffer, "P");
- p = buffer + 1;
- if (years)
- p = pcat (p, years, 'Y');
- if (months)
- p = pcat (p, months, 'M');
- if (weeks)
- p = pcat (p, weeks, 'W');
- if (days)
- p = pcat (p, days, 'D');
- if (hours || minutes || secs){
- *p++ = 'T';
- if (hours)
- p = pcat (p, hours, 'H');
- if (minutes)
- p = pcat (p, minutes, 'M');
- if (secs)
- p = pcat (p, secs, 'S');
- }
-
- return buffer;
-}
-
-int
-isodiff_to_secs (char *str)
-{
- int value, time;
- int years, months, weeks, days, hours, minutes, seconds;
-
- value = years = months = weeks = days = hours = minutes = time = seconds = 0;
- if (*str != 'P')
- return 0;
-
- str++;
- while (*str){
- switch (*str){
- case '0': case '1': case '2': case '3': case '4':
- case '5': case '6': case '7': case '8': case '9':
- value = value * 10 + (*str - '0');
- break;
- case 'Y':
- years = value; value = 0;
- break;
- case 'M':
- if (time)
- minutes = value;
- else
- months = value;
- value = 0;
- break;
- case 'W':
- weeks = value; value = 0;
- break;
- case 'D':
- days = value; value = 0;
- break;
- case 'T':
- value = 0; time = 1;
- break;
- case 'H':
- hours = value; value = 0;
- break;
- case 'S':
- seconds = value; value = 0;
- break;
- }
- str++;
- }
- return seconds + (minutes * 60) + (hours * 3600) +
- (days * 86400) + (weeks * 7 * 86400) +
- (months * 30 * 86400) + (years * 365 * 86400);
}
diff --git a/calendar/cal-util/timeutil.h b/calendar/cal-util/timeutil.h
index 6eaaf63cfb..b32e82d7ce 100644
--- a/calendar/cal-util/timeutil.h
+++ b/calendar/cal-util/timeutil.h
@@ -14,11 +14,7 @@
#include <ical.h>
-time_t time_from_start_duration (time_t start, char *duration);
char *isodate_from_time_t (time_t t);
-int get_time_t_hour (time_t t);
-int isodiff_to_secs (char *str);
-char *isodiff_from_secs (int secs);
time_t time_add_minutes (time_t time, int minutes);
time_t time_add_day (time_t time, int days);
@@ -27,12 +23,6 @@ time_t time_add_month (time_t time, int months);
time_t time_add_year (time_t time, int years);
-/* Returns pointer to a statically-allocated buffer with a string of the form
- * 3am, 4am, 12pm, 08h, 17h, etc.
- * The string is internationalized, hopefully correctly.
- */
-char *format_simple_hour (int hour, int use_am_pm);
-
/* Returns the number of days in the specified month. Years are full years (starting from year 1).
* Months are in [0, 11].
*/
@@ -43,8 +33,6 @@ int time_days_in_month (int year, int month);
*/
time_t time_from_day (int year, int month, int day);
-time_t time_day_hour (time_t t, int hour);
-
/* For the functions below, time ranges are considered to contain the start time, but not the end
* time.
*/
@@ -73,7 +61,6 @@ time_t time_week_end (time_t t);
time_t time_day_begin (time_t t);
time_t time_day_end (time_t t);
-time_t parse_date (char *str);
void print_time_t (time_t t);