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

Jay Hannah jhannah at omnihotels.com
Thu Oct 27 14:03:52 PDT 2005


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



More information about the Omaha-pm mailing list