Next | Pigs in Space | 22 |
Moonpig::DateTime inherits from DateTime but overrides a couple of things
Among them the overloading of + and -
my $then = Moonpig::DateTime->new( month => 4, ... ); my $later = $then + 4; my $earlier = $then - 60 * 15; my $elapsed = Moonpig->env->now() - $then; print "$elapsed seconds since then\n";
my $next_week = Moonpig->env->now() + days(7); sub days { $_[0] * 86400 }
I feared this hack would leak unpleasantly
I thought it might would fail bizarrely one case out of 20
Nope, it worked flawlessly
It's only about 100 lines; check it out
Next | Copyright © 2013 M. J. Dominus |