setDateEnd fix in ICalendarVEvent
Brought to you by:
stuartguthrie
I noticed I couldn't get a proper DTEND date so I
changed the setDateEnd function and seems to work well.
public void setDuration\(String duration\) \{ this.duration = duration; /\* \* Currently, use this duration to create a DateEnd.
This is not optimal
* but works for Apple iCal and is strictly true.
*/
if (getDateStart() != null && getDateEnd() == null) {
//initialize variables
int h = 0;
int m = 0;
int s = 0;
int totalSecs = 0;
//set time to seconds for H,M,S try \{ h =
Integer.parseInt(duration.substring(2,duration.indexOf("H")))*3600;
m =
Integer.parseInt(duration.substring(duration.indexOf("H")+1,duration.indexOf("M")))*60;
s =
Integer.parseInt(duration.substring(duration.indexOf("M")+1,duration.indexOf("S")));
} catch (Exception error) {}
//add times to a total time totalSecs = h + m + s; // Now adjust the dateEnd to dateStart + secs. int dateRepeatUnit = Calendar.SECOND; Calendar workDateEnd = new GregorianCalendar\(\); workDateEnd.setTime\(getDateStart\(\)\); workDateEnd.add\(dateRepeatUnit, totalSecs\); setDateEnd\(workDateEnd.getTime\(\)\); \} \}
Change to setDateEnd()
Logged In: NO
sorry... I mean setDuration for setting DTEND...