--- calaccess.cc.orig	2010-05-16 18:07:23.000000000 -0400
+++ calaccess.cc	2010-12-03 00:36:41.000000000 -0500
@@ -3,6 +3,7 @@
 #include <CComponent.h>
 #include <CRecurrence.h>
 #include <CEvent.h>
+#include <CAlarm.h>
 #include <iostream>
 #include <string>
 #include <sstream>
@@ -21,6 +22,7 @@
 	int mtime;
 	int tzOffset;
 	const char *rrule;
+	int alarm;
 };
 
 extern "C" const char *getAllLocalCalendarsIDs()
@@ -86,7 +88,7 @@
 
 extern "C" const char *addLocalCalendarEntry(int calId, int start, int end, 
 		char *title, char *where, char *descr, 
-		int fullday, int cdate, char *rrule, int rtype)
+		int fullday, int cdate, char *rrule, int rtype, int alarm)
 {
 	bool newEvtRes;
 	int error;
@@ -101,10 +103,8 @@
 	newEvt->setCreatedTime(cdate);
 	newEvt->setLastModified(cdate);
 	newEvt->setAllDay(fullday);
-	if (fullday == 1) {
-		newEvt->setTzOffset(0);
-		newEvt->setTzid(":UTC");
-	}
+	newEvt->setTzOffset(CMulticalendar::MCInstance()->getSystemTimeShift());
+	newEvt->setTzid(CMulticalendar::MCInstance()->getSystemTimeZone());
 
 	cal = mc->getCalendarById(calId, error);
 	if (cal == NULL) {
@@ -122,7 +122,12 @@
 		rec->setRrule(rrules);
 		newEvt->setRecurrence(rec);
 	}
-	
+
+	if (alarm >= 0)
+		newEvt->setAlarmBefore(alarm*60);
+	else
+		newEvt->removeAlarm();
+
 	newEvtRes = cal->addEvent(newEvt, error);
 	if (newEvtRes) {
 		newEvtId = newEvt->getId();
@@ -135,7 +140,7 @@
 
 extern "C" int updateLocalEvent(int cid, char *localId, char *summary,
 		char *descr, char *where, int start, int end, char *rrule,
-		int rtype, int until)
+		int rtype, int until, int alarm)
 {
 	int error;
 
@@ -169,6 +174,11 @@
 		evt->setUntil(until);
 	}
 
+	if (alarm >= 0)
+		evt->setAlarmBefore(alarm*60);
+	else
+		evt->removeAlarm();
+
 	bool res = cal->modifyEvent(evt, error);
 
 	delete cal;
@@ -336,6 +346,9 @@
 		e->rrule = (const char*)strdup(rrule.erase(rrule.size()-1).c_str());
 	}
 
+	int alarm = evt->getAlarmBefore();
+	e->alarm = (alarm == -1 ? -1 : alarm/60);
+
 	delete evt;
 	
 	return 0;
--- cwrapper.py.orig	2010-05-16 17:10:21.000000000 -0400
+++ cwrapper.py	2010-12-03 00:36:41.000000000 -0500
@@ -49,7 +49,8 @@
 			("ctime", c_int),
 			("mtime", c_int),
 			("tzOffset", c_int),
-			("rrule", c_char_p)]
+			("rrule", c_char_p),
+			("alarm", c_int)]
 
 
 def createLocalCalendar(name):
@@ -65,7 +66,8 @@
 	ret = (lib.addLocalCalendarEntry(calId, evt.get_start(), \
 			evt.get_end(), evt.get_title(), evt.get_where(), \
 			evt.get_description(), evt.get_fullday(),\
-			evt.get_cdate(), evt.get_rrule(), evt.get_rtype()))
+			evt.get_cdate(), evt.get_rrule(), evt.get_rtype(), \
+			evt.get_alarm()))
 
 	if not ret:
 		return None
@@ -94,13 +96,13 @@
 	return lib.updateLocalEvent(cid, str(lid), evt.get_title(), \
 			evt.get_description(), evt.get_where(), \
 			evt.get_start(), evt.get_end(), evt.get_rrule(), \
-			evt.get_rtype(), evt.get_until())
+			evt.get_rtype(), evt.get_until(), evt.get_alarm())
 
 def getNewEventById(cid, lid, maxTimestamp):
 	e = EVENT()
 	lib.getEventById(cid, str(lid), pointer(e))
 	if e.ctime < maxTimestamp:
-		return (e.id, e.start, e.end, e.title, e.where, e.descr, e.allday, e.tzOffset, e.rrule)
+		return (e.id, e.start, e.end, e.title, e.where, e.descr, e.allday, e.tzOffset, e.rrule, e.alarm)
 	else:
 		return None
 
@@ -108,6 +110,6 @@
 	e = EVENT()
 	lib.getEventById(cid, str(lid), pointer(e))
 	if e.mtime < maxTimestamp:
-		return (e.id, e.start, e.end, e.title, e.where, e.descr, e.allday, e.tzOffset, e.rrule)
+		return (e.id, e.start, e.end, e.title, e.where, e.descr, e.allday, e.tzOffset, e.rrule, e.alarm)
 	else:
 		return None
--- Event.py.orig	2010-06-20 17:33:20.000000000 -0400
+++ Event.py	2010-12-03 00:36:41.000000000 -0500
@@ -26,7 +26,7 @@
 
 class Event:
 	def __init__(self, title, where, descr, start_time, end_time, \
-			full_day, id, cdate, rrule=None):
+			full_day, id, cdate, rrule=None, alarm=-1):
 		self.title = title
 		self.where = where
 		self.descr = descr
@@ -37,6 +37,7 @@
 		self.id = id
 		self.tzOffset = 0
 		self.rrule = rrule
+		self.alarm = alarm
 
 	def set_tzOffset(self, o):
 		self.tzOffset = o
@@ -137,3 +138,5 @@
 		else:
 			return 0
 
+	def get_alarm(self):
+		return self.alarm
--- erminig_core.py.orig	2010-06-20 17:02:44.000000000 -0400
+++ erminig_core.py	2010-12-03 00:36:41.000000000 -0500
@@ -226,6 +226,7 @@
 		start_time = ""
 		end_time = ""
 		full_day = False
+		alarm = -1
 		if e.recurrence <> None:
 			recurrence = process_recurrence(e.recurrence.text)
 			if not recurrence:
@@ -238,6 +239,9 @@
 			start_time = iso8601ToTimestamp(recurrence['dtstart'])
 			end_time = iso8601ToTimestamp(recurrence['dtend'])
 			fullday = isEventFullDay(recurrence['dtstart'])
+
+			if len(e.reminder) > 0:
+				alarm = int(e.reminder[0].minutes)
 		else:
 			start_time = iso8601ToTimestamp(e.when[0].start_time)
 			end_time = iso8601ToTimestamp(e.when[0].end_time)
@@ -245,19 +249,23 @@
 			# timing event (only date)
 			fullday = isEventFullDay(e.when[0].start_time)
 
+			if len(e.when[0].reminder) > 0:
+				alarm = int(e.when[0].reminder[0].minutes)
+
 		where = e.where[0].value_string
 		description =  e.content.text
 		id = urllib.unquote((e.id.text.rpartition("/"))[2])
 		cdate = time.time()
 
-
 		if (fullday == 1):
+			start_time += time.timezone
+			end_time += time.timezone
 			if ((start_time - end_time) == 0):
 				end_time = start_time + 24*3600
 
 		event = Event(title, where, description, \
 				start_time, end_time, fullday, id,\
-				cdate, rrule=rstring)
+				cdate, rrule=rstring, alarm=alarm)
 		if e.event_status.value == "CANCELED":
 			# remove event locally:
 			removeCancelledEventLocally(localSource, id)
@@ -336,8 +344,10 @@
 	if evt.get_rrule() <> "":
 		rec_data = create_rrule(start_time, end_time, evt.get_rrule())
 		event.recurrence = gdata.calendar.Recurrence(text=rec_data)
+		event.reminder.append(gdata.calendar.Reminder(minutes=evt.get_alarm()));
 	else:
 		event.when.append(gdata.calendar.When(start_time=start_time, end_time=end_time))
+		event.when[0].reminder.append(gdata.calendar.Reminder(minutes=evt.get_alarm()));
 
 	new_event = None
 	try:
@@ -370,7 +380,7 @@
 		update_progress(progress, progress_val)
 
 		event = Event(e[3], e[4], e[5], e[1], e[2], e[6], \
-				e[0], 0, rrule=e[8])
+				e[0], 0, rrule=e[8], alarm=e[9])
 		event.set_tzOffset(e[7])
 		gid = createNewGoogleEvent(event, remoteSource, pid)
 
@@ -442,8 +452,16 @@
 	if evt.get_rrule() <> "":
 		rec_data = create_rrule(start_time, end_time, evt.get_rrule())
 		event.recurrence = gdata.calendar.Recurrence(text=rec_data)
+		if len(event.reminder) > 0:
+			event.reminder[0].minutes = evt.get_alarm()
+		else:
+			event.reminder.append(gdata.calendar.Reminder(minutes=evt.get_alarm()));
 	else:
 		event.when[0] = gdata.calendar.When(start_time=start_time, end_time=end_time)
+		if len(event.when[0].reminder) > 0:
+			event.when[0].reminder[0].minutes = evt.get_alarm()
+		else:
+			event.when[0].reminder.append(gdata.calendar.Reminder(minutes=evt.get_alarm()));
 
 	try:
 		google_api.run_google_action(google_api.gd_client.UpdateEvent, event.GetEditLink().href, event)
@@ -465,7 +483,7 @@
 		update_progress(progress, progress_val)
 
 		event = Event(e[3], e[4], e[5], e[1], e[2], e[6], \
-				e[0], 0, rrule=e[8])
+				e[0], 0, rrule=e[8], alarm=e[9])
 		event.set_tzOffset(e[7])
 		gid = updateGoogleEvent(event, remoteSource, pid)
 
