From e76b691e78e273226cba9284cb8cd22a423319ed Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Fri, 2 Aug 2013 17:23:25 -0500 Subject: bucky2 --- bucky2/t/lastlog.pl | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100755 bucky2/t/lastlog.pl (limited to 'bucky2/t/lastlog.pl') diff --git a/bucky2/t/lastlog.pl b/bucky2/t/lastlog.pl new file mode 100755 index 0000000..5defaf3 --- /dev/null +++ b/bucky2/t/lastlog.pl @@ -0,0 +1,33 @@ +#!/usr/bin/perl +use lib "../lib"; +use Bucky; +my $bucky = new Bucky; +my $today = time - 86400; +my $lastlog = $bucky->db->select("user", "lastseen > $today order by lastseen desc"); +foreach my $user (@$lastlog) + { + my $name = $user->{'username'}; + my $age = get_age($user->{'lastseen'}); + print "$name => $age\n"; + } +sub get_age + { + my ($time) = @_; + my $age = time - $time; + if ($age < 60) + { + return int($age)."s"; + } + $age /= 60; + if ($age < 60) + { + return int($age)."m"; + } + $age /= 60; + if ($age < 60) + { + return int($age)."h"; + } + $age /= 24; + return int($age)."d"; + } -- cgit v1.2.3-70-g09d2