Menu

DURATION

2013-09-12
2013-09-12
  • Caruyer Perrine

    Caruyer Perrine - 2013-09-12

    Hello Michael,
    I'm back with a new request :D
    I want to parse an ics file in wich there is this event :

    BEGIN:VEVENT
    UID:66@education.gouv.fr
    DTSTAMP:20121129T191847Z
    DESCRIPTION:Rentrée scolaire des enseignants
    DTSTART;VALUE=DATE:20080901
    LOCATION:Caen\, Clermont-Ferrand\, Grenoble\, Lyon\, Montpellier\, Nancy-Me
    tz\, Nantes\, Rennes\, Toulouse
    SUMMARY:Rentrée scolaire des enseignants - Zone A
    TRANSP:TRANSPARENT
    END:VEVENT

    There is no DTEND, and no DURATION, are you ok to say that this is not correct ?
    RFC :
    ; Either 'dtend' or 'duration' MAY appear in
    ; a 'eventprop', but 'dtend' and 'duration'
    ; MUST NOT occur in the same 'eventprop'.

    So, I don't know what I will do with this event but it makes me think about DURATION. If I do this :
    ical.getEvents().get(0).getDuration().getValue()
    I have the String value (for example "P1D"). But without parsing it by myself, I can't do many things with it :D (Unless there is a way I don't know ?).
    So that I would like to have the value in milliseconds, and easily add it to the begin date to have the end date ?
    What do you think about this ? :)

    Thanks for reading my request, I'm waiting for your answers :)

    Perrine

     
  • Michael Angstadt

    Hi Perrine,

    There is no DTEND, and no DURATION, are you ok to say that this is not correct ?

    I don't understand what you mean. I parsed your event using biweekly (v0.3.0) and it returned no such validation warning. The fact that your event has no DTEND or DURATION property is a valid use-case. As you have shown, these properties are not required to be part of a VEVENT.

    So, I don't know what I will do with this event but it makes me think about DURATION. If I do this :
    ical.getEvents().get(0).getDuration().getValue()
    I have the String value (for example "P1D"). But without parsing it by myself, I can't do many things with it :D (Unless there is a way I don't know ?).
    So that I would like to have the value in milliseconds, and easily add it to the begin date to have the end date ?

    biweekly actually does parse duration values. The DurationProperty.getValue() method actually returns a Duration object, which contains getter methods for each component of the duration value. Its toString() method generates the encoded string value, which may be what you are seeing.

    :::java
    Duration duration = ical.getEvents().get(0).getDuration().getValue();
    Integer days = duration.getDays();
    Integer hours = duration.getHours();
    String str = duration.toString(); //e.g. "P1D"
    

    There is currently no method that returns the total number of milliseconds. I like that idea, I will add it! Thanks for the suggestion! :D

    -Mike

     
  • Caruyer Perrine

    Caruyer Perrine - 2013-09-12

    Thanks for your answer!
    I'm sorry I did not understand well the RFC, probably because of my bad english :(
    I thought DTEND or DURATION where required.
    When there is no one, it means that the event is really punctual? Like if end date was equal to begin date..

    I'm happy that you like my idea :D

    Perrine

     
  • Michael Angstadt

    It makes sense for DTEND and DURATION to be optional. Sometimes, you do not know how long an event will last!

     

Anonymous
Anonymous

Add attachments
Cancel