From 01339e3ccdcf155e6037f3116bca04c95c4cac53 Mon Sep 17 00:00:00 2001 From: doy Date: Mon, 27 Apr 2009 00:06:04 -0500 Subject: use Time::Duration rather than rolling my own code --- lib/Bot/Games/Game.pm | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/lib/Bot/Games/Game.pm b/lib/Bot/Games/Game.pm index 705817e..f70f5c7 100644 --- a/lib/Bot/Games/Game.pm +++ b/lib/Bot/Games/Game.pm @@ -1,6 +1,7 @@ package Bot::Games::Game; use Bot::Games::OO::Game; use DateTime; +use Time::Duration; has help => ( is => 'ro', @@ -83,17 +84,7 @@ command cmdlist => sub { return join ' ', sort map { '-' . $_ } @$list }; -# XXX: this would be much nicer as an external module, but the only one that -# really does what i want (DateTime::Format::Human::Duration) has only had one -# release, which doesn't pass tests. bleh. -sub _diff_from_now { - my ($dt) = @_; - my $dur = DateTime->now - $dt; - my @units = qw/weeks days hours minutes seconds/; - $dur->in_units(@units); - my @dur_values = map { $dur->$_ . " $_" } grep { $dur->$_ } @units; - return join(', ', @dur_values) . " ago"; -} +sub _diff_from_now { ago(time - shift->epoch, 3) } # this happens in Bot::Games, since we want to add the say method from there #__PACKAGE__->meta->make_immutable; -- cgit v1.2.3-54-g00ecf