aboutsummaryrefslogtreecommitdiffstats
path: root/calendar/cal-util
diff options
context:
space:
mode:
authorFederico Mena Quintero <federico@ximian.com>2001-04-13 00:29:56 +0800
committerFederico Mena Quintero <federico@src.gnome.org>2001-04-13 00:29:56 +0800
commit3b562b0b9f81cdd6cedea7c7c53272a98568e63a (patch)
tree16f563e4357fa6268bbd5930e29f5f17a258e81f /calendar/cal-util
parentb1c4145cd9bde65773aa668939e8557986c205c5 (diff)
downloadgsoc2013-evolution-3b562b0b9f81cdd6cedea7c7c53272a98568e63a.tar
gsoc2013-evolution-3b562b0b9f81cdd6cedea7c7c53272a98568e63a.tar.gz
gsoc2013-evolution-3b562b0b9f81cdd6cedea7c7c53272a98568e63a.tar.bz2
gsoc2013-evolution-3b562b0b9f81cdd6cedea7c7c53272a98568e63a.tar.lz
gsoc2013-evolution-3b562b0b9f81cdd6cedea7c7c53272a98568e63a.tar.xz
gsoc2013-evolution-3b562b0b9f81cdd6cedea7c7c53272a98568e63a.tar.zst
gsoc2013-evolution-3b562b0b9f81cdd6cedea7c7c53272a98568e63a.zip
New function to restart a query for the day view. (query_obj_updated_cb):
2001-04-12 Federico Mena Quintero <federico@ximian.com> * gui/e-day-view.c (update_query): New function to restart a query for the day view. (query_obj_updated_cb): Renamed from obj_updated_cb(); updated for queries instead of calendar clients. (query_obj_removed_cb): Likewise. (cal_opened_cb): Just update_query() instead of queueing reloading all the events. (e_day_view_set_cal_client): Likewise. (e_day_view_set_query): Likewise. (e_day_view_set_selected_time_range): Likewise. (e_day_view_set_days_shown): Likewise. (e_day_view_recalc_work_week): Likewise. (e_day_view_queue_reload_events): Removed function now that events are updated entirely by the query. (e_day_view_reload_events_idle_cb): Likewise. (e_day_view_reload_events): Likewise. (e_day_view_init): Use a pretty arrow instead of GDK_TOP_LEFT_ARROW. * gui/e-week-view.c: Analogous changes to the ones in e-day-view.c. (e_week_view_init): Use a pretty arrow instead of GDK_TOP_LEFT_ARROW. * cal-util/timeutil.c (isodate_from_time_t): Return a g_strdup()ed version of the string instead of a pointer to a static buffer. (time_from_isodate): Resurrected function. Polished up to our current standards of paranoia. * pcs/query.c (func_time_now): New function (time-now). (func_make_time): New function (make-time ISODATE). (func_time_add_day): New function (time-add-day TIME N). (func_time_day_begin): New function (time-day-begin TIME). (func_time_day_end): New function (time-day-end TIME). (func_occur_in_time_range): Use time_t values instead of ints. (match_component): Free the stringized component. Free the ESexp result value. * gui/e-day-view.h: Removed a couple of unused prototypes. * pcs/query.c (query_destroy): Oops, disconnect from the backend. * pcs/cal.c (Cal_get_query): Duplicate the query reference before we return it. * gui/calendar-commands.c (pixmaps): Fixed paths to image files. svn path=/trunk/; revision=9266
Diffstat (limited to 'calendar/cal-util')
-rw-r--r--calendar/cal-util/timeutil.c75
-rw-r--r--calendar/cal-util/timeutil.h1
2 files changed, 74 insertions, 2 deletions
diff --git a/calendar/cal-util/timeutil.c b/calendar/cal-util/timeutil.c
index b48a02b5fa..2d769623aa 100644
--- a/calendar/cal-util/timeutil.c
+++ b/calendar/cal-util/timeutil.c
@@ -9,6 +9,7 @@
*/
#include <string.h>
+#include <ctype.h>
#include <glib.h>
#include "timeutil.h"
@@ -24,15 +25,85 @@ print_time_t (time_t t)
tm->tm_hour, tm->tm_min, tm->tm_sec);
}
+/**
+ * isodate_from_time_t:
+ * @t: A time value.
+ *
+ * Creates an ISO 8601 local time representation from a time value.
+ *
+ * Return value: String with the ISO 8601 representation of the local time.
+ **/
char *
isodate_from_time_t (time_t t)
{
struct tm *tm;
- static char isotime [40];
+ char isotime[40];
tm = localtime (&t);
strftime (isotime, sizeof (isotime)-1, "%Y%m%dT%H%M%S", tm);
- return isotime;
+ return g_strdup (isotime);
+}
+
+/**
+ * time_from_isodate:
+ * @str: Date/time value in ISO 8601 format.
+ *
+ * Converts an ISO 8601 time string into a time_t value.
+ *
+ * Return value: Time_t corresponding to the specified ISO string.
+ **/
+time_t
+time_from_isodate (const char *str)
+{
+ int len;
+ struct tm my_tm;
+ time_t t;
+ int i;
+
+ g_return_val_if_fail (str != NULL, -1);
+
+ /* yyyymmdd[Thhmmss[Z]] */
+
+ len = strlen (str);
+
+ if (!(len == 8 || len == 15 || len == 16))
+ return -1;
+
+ for (i = 0; i < len; i++)
+ if (!((i != 8 && i != 15 && isdigit (str[i]))
+ || (i == 8 && str[i] == 'T')
+ || (i == 15 && str[i] == 'Z')))
+ return -1;
+
+ memset (&my_tm, 0, sizeof (my_tm));
+
+#define digit_at(x,y) (x[y] - '0')
+
+ my_tm.tm_year = (digit_at (str, 0) * 1000 + digit_at (str, 1) * 100 +
+ digit_at (str, 2) * 10 + digit_at (str, 3)) - 1900;
+
+ my_tm.tm_mon = digit_at (str, 4) * 10 + digit_at (str, 5) - 1;
+ my_tm.tm_mday = digit_at (str, 6) * 10 + digit_at (str, 7);
+
+ if (len > 8) {
+ my_tm.tm_hour = digit_at (str, 9) * 10 + digit_at (str, 10);
+ my_tm.tm_min = digit_at (str, 11) * 10 + digit_at (str, 12);
+ my_tm.tm_sec = digit_at (str, 13) * 10 + digit_at (str, 14);
+ }
+
+ my_tm.tm_isdst = -1;
+
+ t = mktime (&my_tm);
+
+ if (len == 16) {
+#if defined(HAVE_TM_GMTOFF)
+ t -= my_tm.tm_gmtoff;
+#elsif defined(HAVE_TIMEZONE)
+ t -= timezone;
+#endif
+ }
+
+ return t;
}
time_t
diff --git a/calendar/cal-util/timeutil.h b/calendar/cal-util/timeutil.h
index 730c7dc089..04f1ca4867 100644
--- a/calendar/cal-util/timeutil.h
+++ b/calendar/cal-util/timeutil.h
@@ -17,6 +17,7 @@
char *isodate_from_time_t (time_t t);
+time_t time_from_isodate (const char *str);
time_t time_add_minutes (time_t time, int minutes);
time_t time_add_day (time_t time, int days);