aboutsummaryrefslogtreecommitdiffstats
path: root/calendar/cal-util
diff options
context:
space:
mode:
authorJP Rosevear <jpr@ximian.com>2001-10-24 01:40:55 +0800
committerJP Rosevear <jpr@src.gnome.org>2001-10-24 01:40:55 +0800
commit31675e8d99ca20c77f322f69bccc8eb64e4ca63e (patch)
tree38f83373eb1fae8436c68f669d0a1e28d0e7a656 /calendar/cal-util
parent2ea98fb813283a72698682e3f51f3ae13b614889 (diff)
downloadgsoc2013-evolution-31675e8d99ca20c77f322f69bccc8eb64e4ca63e.tar
gsoc2013-evolution-31675e8d99ca20c77f322f69bccc8eb64e4ca63e.tar.gz
gsoc2013-evolution-31675e8d99ca20c77f322f69bccc8eb64e4ca63e.tar.bz2
gsoc2013-evolution-31675e8d99ca20c77f322f69bccc8eb64e4ca63e.tar.lz
gsoc2013-evolution-31675e8d99ca20c77f322f69bccc8eb64e4ca63e.tar.xz
gsoc2013-evolution-31675e8d99ca20c77f322f69bccc8eb64e4ca63e.tar.zst
gsoc2013-evolution-31675e8d99ca20c77f322f69bccc8eb64e4ca63e.zip
convert an icaltimetype to a tm (tm_to_icaltimetype): vice versa
2001-10-23 JP Rosevear <jpr@ximian.com> * cal-util/timeutil.c (icaltimetype_to_tm): convert an icaltimetype to a tm (tm_to_icaltimetype): vice versa * cal-util/timeutil.h: new protos * conduits/calendar/calendar-conduit.c: replace all mktime and localtime calls (except for debugging calls) * conduits/todo/todo-conduit.c: ditto (comp_from_remote_record): make sure the completed time is in UTC svn path=/trunk/; revision=13946
Diffstat (limited to 'calendar/cal-util')
-rw-r--r--calendar/cal-util/timeutil.c44
-rw-r--r--calendar/cal-util/timeutil.h7
2 files changed, 51 insertions, 0 deletions
diff --git a/calendar/cal-util/timeutil.c b/calendar/cal-util/timeutil.c
index f960346477..986971ef37 100644
--- a/calendar/cal-util/timeutil.c
+++ b/calendar/cal-util/timeutil.c
@@ -520,3 +520,47 @@ time_from_isodate (const char *str)
return icaltime_as_timet_with_zone (tt, utc_zone);
}
+struct tm
+icaltimetype_to_tm (struct icaltimetype *itt)
+{
+ struct tm tm;
+
+ 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;
+ }
+
+ tm.tm_mday = itt->day;
+ tm.tm_mon = itt->month - 1;
+ tm.tm_year = itt->year - 1900;
+ tm.tm_isdst = -1;
+
+ return tm;
+}
+
+struct icaltimetype
+tm_to_icaltimetype (struct tm *tm, gboolean is_date)
+{
+ struct icaltimetype itt;
+
+ memset (&itt, 0, sizeof (struct icaltimetype));
+
+ if (!is_date) {
+ itt.second = tm->tm_sec;
+ itt.minute = tm->tm_min;
+ itt.hour = tm->tm_hour;
+ }
+
+ itt.day = tm->tm_mday;
+ itt.month = tm->tm_mon + 1;
+ itt.year = tm->tm_year+ 1900;
+
+ itt.is_utc = 0;
+ itt.is_date = is_date;
+
+ return itt;
+}
+
diff --git a/calendar/cal-util/timeutil.h b/calendar/cal-util/timeutil.h
index 1ae0b45f72..2ca61b45a2 100644
--- a/calendar/cal-util/timeutil.h
+++ b/calendar/cal-util/timeutil.h
@@ -109,4 +109,11 @@ time_t time_day_end_with_zone (time_t time, icaltimezone *zone);
void time_to_gdate_with_zone (GDate *date, time_t time, icaltimezone *zone);
+/**************************************************************************
+ * struct tm manipulation
+ **************************************************************************/
+
+struct tm icaltimetype_to_tm (struct icaltimetype *itt);
+struct icaltimetype tm_to_icaltimetype (struct tm *tm, gboolean is_date);
+
#endif