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

[Omaha.pm] subclassing Class::Date



I love Class::Date. Omni2::Control::DateTime is our subclass of it, and it lets you write some cool code.  :)
 
- "300s"    is just spiffy.  :)
 
j
 
 
BEFORE
   my $now = time();
   my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($now - 300);
   my $datestring=sprintf("%04d-%02d-%02d %02d:%02d",($year + 1900),($mon + 1),$mday,$hour,$min);

AFTER
   my $datestring = (Omni2::Control::DateTime->new() - "300s")->format("%Y-%m-%d %H:%M");