summaryrefslogtreecommitdiff
path: root/lib/VNDB/Func.pm
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2012-01-10 15:44:32 +0100
committerYorhel <git@yorhel.nl>2012-01-10 15:44:32 +0100
commit7f48af30ed456688391e46b1a577c5907cdd7be7 (patch)
tree468dde27c392eab5af23e05e87f452a622c6316e /lib/VNDB/Func.pm
parent3ea8eef12df3e84645b59301211cd233b6c27a2d (diff)
Allow one fractional digit for VN votes
The interface to set a non-integer vote isn't very nice, but at least it works. Or so I hope.
Diffstat (limited to 'lib/VNDB/Func.pm')
-rw-r--r--lib/VNDB/Func.pm7
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/VNDB/Func.pm b/lib/VNDB/Func.pm
index 91659f13..4f564a18 100644
--- a/lib/VNDB/Func.pm
+++ b/lib/VNDB/Func.pm
@@ -9,7 +9,7 @@ use POSIX 'strftime', 'ceil', 'floor';
use VNDBUtil;
our @EXPORT = (@VNDBUtil::EXPORT, qw|
clearfloat cssicon tagscore mt minage fil_parse fil_serialize parenttags
- childtags charspoil imgpath imgurl
+ childtags charspoil imgpath imgurl fmtvote
|);
@@ -195,5 +195,10 @@ sub imgurl {
}
+# Formats a vote number.
+sub fmtvote {
+ return !$_[0] ? '-' : $_[0] % 10 == 0 ? $_[0]/10 : sprintf '%.1f', $_[0]/10;
+}
+
1;