Yitzchak Scott-Thoennes wrote:
> 
> Is there any documentation of what api a DateTime::Event:: module
> should provide, as http://datetime.perl.org/developer/calendar.html
> does for DateTime::Calendar:: ?
> 

DateTime::Set provides a base API that can be used to make factories.

This is the API used by DateTime::Event::Sunrise.

DateTime::Event::FourthofJuly uses a modified version, through
DateTime::Event::Recurrence.

  package DateTime::Event::FourthofJuly;
  use DateTime::Event::Recurrence;
  [...]
  sub fourth_of_july {
    DateTime::Event::Recurrence->yearly(
        months => 7,
        days   => 4,
    );
  }

The API provides the following methods:

  next( dt )
  previous( dt )
  current( dt )
  closest( dt )

  iterator( span )
  as_list( span )
  count( span )

and a few others. You can also 'add' or 'subtract' to an event to
generate other events:

  $fourth_aug = $fourth_july->add( months => 1 );
  print $fourth_aug->closest( $now )->datetime;

Events can be combined using 'union', 'intersection', and 'complement'.

[...]
> 
> [3] Daf yomi is a schedule for learning the Talmud Bavli, one folio
> per day.  It has fixed 2711 day cycles, the current cycle beginning
> 9/29/1997.  See http://dafyomi.co.il/calendars/calendar.htm Properly
> speaking, this isn't a calendar (a system describing time units and
> their interrelationships) but a schedule.  But in DateTime terms, it
> looks more like a calendar than anything else.

For example (tested):

  use DateTime::Event::Recurrence;

  sub daf_yomi {
    DateTime::Event::Recurrence->daily(
        interval => 2711,
        start  => DateTime->new( year => 1997, month => 9, day => 29 )
    );
  }

  my $daf_yomi = daf_yomi;
  print "Last ", $daf_yomi->previous( DateTime->now )->datetime, "\n";
  print "Next ", $daf_yomi->next( DateTime->now )->datetime, "\n";

  # Last 1997-09-29T00:00:00
  # Next 2005-03-02T00:00:00


- Flavio S. Glock

Reply via email to