1 package Gitalist::Utils;
4 use Exporter qw/import/;
14 if ( $age > 60 * 60 * 24 * 365 * 2 ) {
15 $age_str = ( int $age / 60 / 60 / 24 / 365 );
16 $age_str .= " years ago";
18 elsif ( $age > 60 * 60 * 24 * ( 365 / 12 ) * 2 ) {
19 $age_str = int $age / 60 / 60 / 24 / ( 365 / 12 );
20 $age_str .= " months ago";
22 elsif ( $age > 60 * 60 * 24 * 7 * 2 ) {
23 $age_str = int $age / 60 / 60 / 24 / 7;
24 $age_str .= " weeks ago";
26 elsif ( $age > 60 * 60 * 24 * 2 ) {
27 $age_str = int $age / 60 / 60 / 24;
28 $age_str .= " days ago";
30 elsif ( $age > 60 * 60 * 2 ) {
31 $age_str = int $age / 60 / 60;
32 $age_str .= " hours ago";
34 elsif ( $age > 60 * 2 ) {
35 $age_str = int $age / 60;
36 $age_str .= " min ago";
40 $age_str .= " sec ago";
43 $age_str .= " right now";
49 # Crappy heuristic - does the first line or so look printable?
50 return $_[0] !~ /^[[:print:]]+$ (?: \s ^[[:print:]]+$ )?/mx;
59 Gitalist::Utils - trivial utils for Gitalist
65 Turns an integer number of seconds into a string.
69 Check whether a string is binary according to C<-B>.
73 See L<Gitalist> for authors.
77 See L<Gitalist> for the license.