summaryrefslogtreecommitdiff
path: root/lib/VNDB/Func.pm
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2008-11-12 12:41:37 +0100
committerYorhel <git@yorhel.nl>2008-11-12 12:41:37 +0100
commit7f898c439eb139537545eda6eb3ccc580ac8460b (patch)
treeed1f197846ca2b95db5135fa2283746a4088ba62 /lib/VNDB/Func.pm
parentfadb037c536c60c91bf978c2604ca9eab818f3ff (diff)
Created VNDB::Func for a few small and often used functions, split CommonHTML in LayoutHTML, and abstracted the browser generation
I was planning to commit often, but I still end up doing everything in one commit >.>
Diffstat (limited to 'lib/VNDB/Func.pm')
-rw-r--r--lib/VNDB/Func.pm26
1 files changed, 26 insertions, 0 deletions
diff --git a/lib/VNDB/Func.pm b/lib/VNDB/Func.pm
new file mode 100644
index 00000000..9e948e0d
--- /dev/null
+++ b/lib/VNDB/Func.pm
@@ -0,0 +1,26 @@
+
+package VNDB::Func;
+
+use strict;
+use warnings;
+use Exporter 'import';
+use POSIX 'strftime';
+our @EXPORT = qw| shorten date |;
+
+
+# I would've done this as a #define if this was C...
+sub shorten {
+ my($str, $len) = @_;
+ return length($str) > $len ? substr($str, 0, $len-3).'...' : $str;
+}
+
+
+# argument: unix timestamp
+# return value: yyyy-mm-dd
+# (maybe an idea to use cgit-style ages for recent timestamps)
+sub date {
+ return strftime '%Y-%m-%d', gmtime shift;
+}
+
+
+1;