Menu

#8 setDateEnd fix in ICalendarVEvent

open
nobody
None
5
2006-03-07
2006-03-07
Anonymous
No

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\(\)\);
    \}
\}

Discussion

  • Nobody/Anonymous

    Change to setDateEnd()

     
  • Nobody/Anonymous

    Logged In: NO

    sorry... I mean setDuration for setting DTEND...

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.