summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordoy <doy@tozt.net>2009-04-27 00:06:04 -0500
committerdoy <doy@tozt.net>2009-04-27 00:06:04 -0500
commit01339e3ccdcf155e6037f3116bca04c95c4cac53 (patch)
treeaff0f3c0cc6b179b291e758109d56bf04c75d005
parent13c3bb1f47c5b019e853587c7da881026ce22d93 (diff)
downloadbot-games-01339e3ccdcf155e6037f3116bca04c95c4cac53.tar.gz
bot-games-01339e3ccdcf155e6037f3116bca04c95c4cac53.zip
use Time::Duration rather than rolling my own code
-rw-r--r--lib/Bot/Games/Game.pm13
1 files 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;