Re: DateTime::Event::Cron and limiting infinite sets
Hi Sam. I've cc'd the datetime mailing list so that they can chime in if they want. I am trying to write a converter for crontab entries into another format (iCal). Unfortunately I need a limited recurrence set as the output module does not allow infinite sets. I thought that using the %parms or the %set_parms I would be able to limit the Set produced using from_cron and then pass that on as a finite DateTime::Set to the other module. Should the approach I am taking (to limit the resulting Set using a span) work? When searching on Google I found very limited results for use of the DateTime::Event::Cron module and so I wonder if you could point me in a direction for reference information. Do you have any other suggestions or ideas? It sounds to me like you're trying to translate one grammar (cron) into another (ICal). Alternatively, if you can get the constraints expressed as recurrences and sets, then you need an ICal generator that will produce the results you want. Currently, DateTime::Event::Cron is not using the DateTime::Set logic internally to produce its results (I did this for speed at one point and keep meaning to run some benchmarks with the more recent datetime code to see how it compares...but...time and all). Short of converting directly from cron grammar to ICal grammar, it seems to me that using sets as an intermediary would be the natural way to go, but I'm not aware of any Set to ICal generators (indeed, I'm not certain that all sets can even be expressed as ICal strings). Have I misunderstood your question? Matt P.S. Here is the code I am using to try and restrict the returned set where $now is a time in the last year and $end_date is $now + one year: %set_parms = (cron = $_, after = $now, before = $end_date); $cron_entry = DateTime::Event::Cron-from_cron(%set_parms);
Re: DateTime::Event::Cron and limiting infinite sets
I am trying to write a converter for crontab entries into another format (iCal). Unfortunately I need a limited recurrence set as the output module does not allow infinite sets. I thought that using the %parms or the %set_parms I would be able to limit the Set produced using from_cron and then pass that on as a finite DateTime::Set to the other module. Should the approach I am taking (to limit the resulting Set using a span) work? Yes - if the set has up to 200 elements (that's an internal hard limit), DateTime::Format::ICal should do the right thing: print DateTime::Format::ICal-format_recurrence( $set ); DateTime::Format::ICal can only format infinite sets which were created either with DateTime::Event::ICal or with DateTime::Event::Recurrence. - Flavio S. Glock
Re: DateTime::Event::Cron and limiting infinite sets
On Wed, 6 Apr 2005 [EMAIL PROTECTED] wrote: Yes - if the set has up to 200 elements (that's an internal hard limit), DateTime::Format::ICal should do the right thing: Why the internal hard limit? If people want to use up all their memory, that's their problem. A warning in the docs is good, but just giving up at an arbitrary number just makes the software less usefull. -dave /*=== VegGuide.Orgwww.BookIRead.com Your guide to all that's veg. My book blog ===*/
Re: DateTime::Event::Cron and limiting infinite sets
On Wed, 6 Apr 2005 [EMAIL PROTECTED] wrote: Yes - if the set has up to 200 elements (that's an internal hard limit), DateTime::Format::ICal should do the right thing: Why the internal hard limit? If people want to use up all their memory, that's their problem. A warning in the docs is good, but just giving up at an arbitrary number just makes the software less useful. I think this can be fixed - I'll try and make some tests. - Flavio S. Glock
Re: DateTime::Event::Cron and limiting infinite sets
On Wed, 6 Apr 2005 [EMAIL PROTECTED] wrote: Yes - if the set has up to 200 elements (that's an internal hard limit), [...] Why the internal hard limit? If people want to use up all their memory, that's their problem. A warning in the docs is good, but just giving up at an arbitrary number just makes the software less useful. This is fixed now - see DateTime::Set 0.21 in CVS. I'll wait a few hours before uploading to CPAN - there may be bugs around. - Flavio S. Glock
Re: DateTime::Event::Cron and limiting infinite sets
On Wed, 6 Apr 2005 [EMAIL PROTECTED] wrote: Why the internal hard limit? If people want to use up all their memory, that's their problem. A warning in the docs is good, but just giving up at an arbitrary number just makes the software less useful. I think this can be fixed - I'll try and make some tests. One possibility is to simply return undef for methods that might cause infinite loops when we don't know for certain they won't. Calculating whether or not this can happen is probably possible in some cases (defined start end), and in others we can offer a constructor flag. -dave /*=== VegGuide.Orgwww.BookIRead.com Your guide to all that's veg. My book blog ===*/
Re: DateTime::Event::Cron and limiting infinite sets
Dave Rolsky wrote: One possibility is to simply return undef for methods that might cause infinite loops when we don't know for certain they won't. Calculating whether or not this can happen is probably possible in some cases (defined start end), and in others we can offer a constructor flag. There is an internal method called is_too_complex() that could be included in the api. if ( $set-max-is_infinite || $set-min-is_infinite ) { return set is not countable; } elsif ( $set-is_too_complex ) { print this will take a big while; return $set-count; } else { return $set-count; } With version 0.21 you can use $set-count on too complex sets. Infinite sets still return undef. - Flavio S. Glock