Sign In  Sign Up Live-Chat

Quickly determine next occurence based on date / time

Last post 04-07-2008, 6:15 PM by salman.sarfraz. 7 replies.
Sort Posts: Previous Next
  •  09-15-2006, 12:00 AM 56817

    Quickly determine next occurence based on date / time

    Hi,

    I am just starting to use iCalendar so I might have missed something. However what I'd like to be able to do is to get the next occurence given a specific date / time. Instead of either getting all occurences or occurences within a time frame (I don't know whether a given pattern might fall into my time frame), I simply want to pass in a date / time and have the next occurence (date / time again) be returned or DateTime.MinValue if there isn't any next occurence.

    Any hints on this?

    Regards

    Kai
     
  •  09-15-2006, 4:42 PM 56873 in reply to 56817

    Re: Quickly determine next occurence based on date / time

    Good question. I'm sure it was discussed before, but I cannot find a relevant post.

    The problem is that it is not computationally possible to determine just "next" occurrence after an arbitrary date without the pattern internally calculating all occurrences from the beginning of the pattern. Hence the current API that either requests you to provide a window of dates where you want occurrences calculated or calculates all occurrences of the pattern.


    Roman Korchagin
    Lead Developer, Aspose Auckland Team
     
  •  09-15-2006, 4:47 PM 56874 in reply to 56873

    Re: Quickly determine next occurence based on date / time

    An easy example that comes to mind is: "Friday, Every 2nd week".

    Such a pattern only makes sense if it has a start date. Without a start date you cannot tell which week is second (even) and which is first (odd).

    One has to calculate all occurrences from the start date of the pattern, otherwise it is not known which week to pick. I hope you can see that.


    Roman Korchagin
    Lead Developer, Aspose Auckland Team
     
  •  09-17-2006, 10:51 PM 56927 in reply to 56874

    Re: Quickly determine next occurence based on date / time

    Roman,

    of course, you would have to pick the start date and then apply the pattern to determine correct occurences. However I was thinking of it more like a "convenience" function:

    I supply a date on / after which I'm interested in the next occurence. Internally the class could then do the pattern calculation and stop if it hits a date / time on / after the supplied date. If there isn't any occurence being calculated for dates on / after the supplied date, DateTime.MinValue would be returned.

    Hope this makes sense

    Kai
     
  •  03-26-2008, 3:39 PM 119347 in reply to 56927

    Re: Quickly determine next occurence based on date / time

    A suggestion for iCalender users who want to create their own "NextDate" function:

    Call GenerateOccurrences(DateTime.Now, dateEndRange) within a loop in which you offset dateEndRange with a successively larger "frequency", e.g. dateEndRange = Now.AddHours(1), then dateEndRange = Now.AddDays(1)... until the resulting DateCollection.Count is > 0.  Return the first date in that collection.

    Brute force method, but lets you avoid generating & storing huge date collections when you just care about the next date.

    (Any comments, Roman?)

    --Tom

     
  •  04-02-2008, 7:53 AM 120316 in reply to 56873

    Re: Quickly determine next occurence based on date / time

    I disagree that it's "computationally impossible" to determine the next occurrence of a pattern.  If I give you a "from" date and a count, it should be possible to get the next X occurrences very easily.  Just process as if the date range were specified from the "from" date until MaxDate, and stop when X number of occurrences have been found.

    This is actually important to me, and one of the reasons I'm looking at your component in the first place.  I need an RRule evaluation algorithm or package to do exactly this.

    Since I'm here, I may as well ask my other question.  I have a licensing question.  At most, my current project will have two developers that actually need to touch the calendaring functions at all.  But there are 12 other developers that will need to have the library installed so that they can build.  We don't need everyone to be actively developing with the library, so the site license seems excessive.  We just need them to be able to work on their parts of the project.  Does your licensing allow for this?

     
  •  04-04-2008, 2:42 AM 120737 in reply to 120316

    Re: Quickly determine next occurence based on date / time

    Hi,

    Currently we do not have any immediate plans to implement this feature in the near future.
    Sorry for the inconvenience.


    Oleg Korostylev
    Lead Developer
    Aspose Vladivostok Team
    About Us
    Contact Us
     
  •  04-07-2008, 6:15 PM 121110 in reply to 120316

    Re: Quickly determine next occurence based on date / time

    MelGrubb:

    I have a licensing question.  At most, my current project will have two developers that actually need to touch the calendaring functions at all.  But there are 12 other developers that will need to have the library installed so that they can build.  We don't need everyone to be actively developing with the library, so the site license seems excessive.  We just need them to be able to work on their parts of the project.  Does your licensing allow for this?

    Dear Mel,

    For sales inquiries, we use Aspose.Purchase forum. I have created an inquiry in Aspose.Purchase forum on your behalf and answered it. You may access it using this URL,  http://www.aspose.com/community/forums/thread/121106.aspx

    Have a good time.


    Many Thanks & Kind Regards,

    Yours Truly,

    Salman Sarfraz
    Team Leader,
    Aspose Service Team
    Contact Us
    Aspose - The .NET and Java Component Publisher
     
View as RSS news feed in XML