package TimeBO; # BO to tell the time use warnings; use strict; use Carp; # We need the day of Today and represent it in a long format # Today() gives $year, $month and $day in a list # Date_to_Text_long gives p.e. Thursday, February 2nd 2006 use DateTime; # Because we want to pass the time around use OO::TO::TimeTO; sub new { my $class = shift; my $self = { TIMETO => undef, }; my $closure = sub { my $field = shift; if (@_) { $self->{$field} = shift; } return $self->{$field}; }; bless ($closure,$class); return $closure; } # a public accessor to set DATE sub setDate { my $closure = $_[0]; my $date = DateTime->now(); my $timeTO = TimeTO->new(); $timeTO->setDate( $date->ymd() ); $timeTO->setTime( $date->hms() ); setTimeTO( $closure, $timeTO ); } # a private setter for TIMETO sub setTimeTO { caller(0) eq __PACKAGE__ || confess "setTimeTO is a private method"; &{ $_[0] }("TIMETO", @_[1..$#_]); } # a public getter for TIMETO sub getTimeTO { &{ $_[0] }("TIMETO"); } 1;