From 3e69c36a0a0e81f1e98903c7c88d87c2353cde46 Mon Sep 17 00:00:00 2001 From: Andrew McMillan Date: Tue, 13 Dec 2011 14:27:24 +1300 Subject: [PATCH] Fix handling of date/datetime choice in EventEdit. --- src/com/morphoss/acal/activity/EventEdit.java | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/com/morphoss/acal/activity/EventEdit.java b/src/com/morphoss/acal/activity/EventEdit.java index 3330f84..36c4a5f 100644 --- a/src/com/morphoss/acal/activity/EventEdit.java +++ b/src/com/morphoss/acal/activity/EventEdit.java @@ -682,6 +682,14 @@ public class EventEdit extends AcalActivity implements OnGestureListener, OnTouc else { if ( Constants.LOG_DEBUG ) Log.println(Constants.LOGD, TAG,"The timezone did not change from "+oldTzId+" to "+newTzId+", EndTzId was "+endTzId); } + if ( newEnd.isDate() ) newEnd.setDaySecond(0); + if ( !newDateTime.before(newEnd) ) { + newEnd = newDateTime.clone(); + if ( newEnd.isDate() ) + newEnd.addDays(1); + else + newEnd.addSeconds(3600); + } event.setField(EVENT_FIELD.startDate, newDateTime); event.setField(EVENT_FIELD.endDate, newEnd); updateLayout(); @@ -690,8 +698,16 @@ public class EventEdit extends AcalActivity implements OnGestureListener, OnTouc case END_DATE_DIALOG: end.setAsDate(start.isDate()); - if ( end.before(start) ) end = start.clone(); + if ( end.isDate() ) end.setDaySecond(0); + if ( !start.before(end) ) { + end = start.clone(); + if ( end.isDate() ) + end.addDays(1); + else + end.addSeconds(3600); + } if ( end.isDate() ) { + end.setDaySecond(0); // People expect an event starting on the 13th and ending on the 14th to be for // two days. For iCalendar it is one day, so we display the end date to be // one day earlier than the actual setting, if we're viewing -- 2.11.4.GIT