aboutsummaryrefslogtreecommitdiffstats
path: root/calendar/cal-util/timeutil.c
diff options
context:
space:
mode:
Diffstat (limited to 'calendar/cal-util/timeutil.c')
-rw-r--r--calendar/cal-util/timeutil.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/calendar/cal-util/timeutil.c b/calendar/cal-util/timeutil.c
index f887a8df37..bbce9b82d6 100644
--- a/calendar/cal-util/timeutil.c
+++ b/calendar/cal-util/timeutil.c
@@ -10,6 +10,39 @@
#include <string.h>
#include "timeutil.h"
+
+
+/**
+ * time_from_icaltimetype:
+ * @itt: A struct icaltimetype value.
+ *
+ * Converts a struct icaltimetype value into a time_t value. Does not deal with
+ * timezones.
+ *
+ * Return value: A time_t value.
+ **/
+time_t
+time_from_icaltimetype (struct icaltimetype itt)
+{
+ struct tm tm;
+
+ /* FIXME: this does not handle timezones */
+
+ memset (&tm, 0, sizeof (tm));
+
+ tm.tm_year = itt.year - 1900;
+ tm.tm_mon = itt.month - 1;
+ tm.tm_mday = itt.day;
+
+ if (!itt.is_date) {
+ tm.tm_hour = itt.hour;
+ tm.tm_min = itt.minute;
+ tm.tm_sec = itt.second;
+ }
+
+ return mktime (&tm);
+}
+
#define digit_at(x,y) (x [y] - '0')
time_t