[EMAIL PROTECTED] wrote:
>
> > > I classified it as a spreadsheet because when
> > > you redefine a "cell", the
> > > others are automatically "recalculated".
Now you can even do this:
$dtes->set( 'birthday', DateTime->new( year=>1964, month=>12,
day=>14 ) );
my @age = $dtes->get( 'age' )->deltas;
$dtes->set( 'age', DateTime::Duration->new( years => 20 ) );
my $birthday = $dtes->get( 'birthday' )->datetime;
Cells can have 'bidirectional' relations:
You can set 'birthday', and then read the age.
Or, you set 'age', and then read the birthday datetime.
This is how this thing was setup:
my $dtes = DateTime::Event::Spreadsheet->new;
$dtes->set_action( 'birthday',
sub {
$_[0]->set_function( 'age',
sub { DateTime->now - $_[0]->get( 'birthday' ) } ),
},
);
$dtes->set_action( 'age',
sub {
$_[0]->set_function( 'birthday',
sub { DateTime->now - $_[0]->get( 'age' ) } ),
},
);
In english:
when 'birthday' is set, put a function in 'age' that calculates
now-birthday.
when 'age' is set, put a function in 'birthday' that calculates now-age.
Download:
http://www.ipct.pucrs.br/flavio/perl/DateTime-Event-Spreadsheet-0.0_3.pl
- Flavio S. Glock