Menu

All day event?

Anonymous
2015-10-27
2015-11-01
  • Anonymous

    Anonymous - 2015-10-27

    Thanks for the iCal parser. It will save me a ton of work. I have a couple of questions (which I also asked in an earlier question I had posted in response to your answer. So, feel free to skip it if you get to those first).

    1. When parsing an iCal, how can I find if VEvent is an all day event? I looked at the class methods and I don't see any which returns the value. Am I just missing something?
    2. I would like to get the timezone info, but the following code returns null.
      ICalReader iCalReader = new ICalReader(f);
      TimezoneInfo tzi = iCalReader.getTimezoneInfo();

    Thank you for your help.

     
  • Michael Angstadt

    When parsing an iCal, how can I find if VEvent is an all day event?

    There's nothing in the iCalendar specification that allows you to flag an event as an "all-day" event. You have to just look at the start and end dates, and judge for yourself. I think most iCalendar consumers consider an event to be "all-day" if the start and end dates are 1 day apart. Something like this:

    :::java
    public static boolean isAllDay(VEvent event){
      ICalDate start = event.getDateStart().getValue();
      ICalDate end = event.getDateEnd().getValue();
      if (start.hasTime() || end.hasTime()){
        return false;
      }
    
      Calendar c = Calendar.getInstance();
      c.setTime(start);
      c.add(Calendar.DATE, 1);
      Date expectedEnd = c.getTime();
    
      return end.equals(expectedEnd);
    }
    

    I would like to get the timezone info, but the following code returns null.

    You must call "getTimezoneInfo()" after calling "readNext()".

    :::java
    ICalReader reader = ...
    ICalendar ical = reader.readNext();
    TimezoneInfo tzinfo = reader.getTimezoneInfo();
    
     
  • Anonymous

    Anonymous - 2015-10-30

    Thank you for the tip re. time zone. Re. all day event, is this not standard?

    X-MICROSOFT-CDO-ALLDAYEVENT:TRUE

     
  • Michael Angstadt

    No, that is not a standard iCalendar property. Microsoft products probably recognize it, but other iCalendar consumers may not.

     

Anonymous
Anonymous

Add attachments
Cancel