aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/Utils.pm
diff options
context:
space:
mode:
authorMatthew Somerville <matthew-github@dracos.co.uk>2016-09-20 16:19:37 +0100
committerMatthew Somerville <matthew-github@dracos.co.uk>2016-09-20 16:19:37 +0100
commit1c5c614af7a0265bd296ef67c0d342b27898185c (patch)
tree26e1199c1010e8d88c87e4821c7f82c3494db5d0 /perllib/Utils.pm
parent33be8df8f21f6ec5cee9c4675847b8e26f72f96b (diff)
Some tests for the Util modules.
Diffstat (limited to 'perllib/Utils.pm')
-rw-r--r--perllib/Utils.pm17
1 files changed, 3 insertions, 14 deletions
diff --git a/perllib/Utils.pm b/perllib/Utils.pm
index 87c1a10d6..84c09d09d 100644
--- a/perllib/Utils.pm
+++ b/perllib/Utils.pm
@@ -15,6 +15,7 @@ use Encode;
use File::Slurp qw();
use mySociety::GeoUtil;
use mySociety::Locale;
+use FixMyStreet;
=head2 convert_latlon_to_en
@@ -199,7 +200,7 @@ sub prettify_duration {
$s = int(($s+60*60*12)/60/60/24)*60*60*24;
} elsif ($nearest eq 'hour') {
$s = int(($s+60*30)/60/60)*60*60;
- } elsif ($nearest eq 'minute') {
+ } else { # minute
$s = int(($s+30)/60)*60;
return _('less than a minute') if $s == 0;
}
@@ -221,7 +222,7 @@ sub _part {
$str = mySociety::Locale::nget("%d day", "%d days", $i);
} elsif ($m == 60*60) {
$str = mySociety::Locale::nget("%d hour", "%d hours", $i);
- } elsif ($m == 60) {
+ } else {
$str = mySociety::Locale::nget("%d minute", "%d minutes", $i);
}
push @$o, sprintf($str, $i);
@@ -229,17 +230,5 @@ sub _part {
}
}
-=head2 read_file
-
-Reads in a UTF-8 encoded file using File::Slurp and decodes it from UTF-8.
-This appears simplest, rather than getting confused with binmodes and so on.
-
-=cut
-sub read_file {
- my $filename = shift;
- my $data = File::Slurp::read_file( $filename );
- $data = Encode::decode( 'utf8', $data );
- return $data;
-}
1;