[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Omaha.pm] Class::Date easy e zeeness



Life sure is easier using Class::Date objects than it is
using/converting strings representing datetimes...

Before

  use Date::Calc qw(Today_and_Now);

  my @today = Date::Calc::Today;
  my @ad = Date::Calc::Add_Delta_Days(@today,14);
  my @dd = Date::Calc::Add_Delta_Days(@ad,2);
  my $ad = "$ad[0]-$ad[1]-$ad[2]";
  my $dd = "$dd[0]-$dd[1]-$dd[2]";

After

  use Control::DateTime;   # Our Class::Date wrapper

  my $ad = Control::DateTime->new('today') + "14D";
  my $dd = $ad + "2D";

Wheee!

j