summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/VNDB/Func.pm25
-rw-r--r--lib/VNDB/Handler/Producers.pm5
2 files changed, 27 insertions, 3 deletions
diff --git a/lib/VNDB/Func.pm b/lib/VNDB/Func.pm
index 9e948e0d..0bfd58de 100644
--- a/lib/VNDB/Func.pm
+++ b/lib/VNDB/Func.pm
@@ -5,7 +5,7 @@ use strict;
use warnings;
use Exporter 'import';
use POSIX 'strftime';
-our @EXPORT = qw| shorten date |;
+our @EXPORT = qw| shorten date datestr |;
# I would've done this as a #define if this was C...
@@ -23,4 +23,25 @@ sub date {
}
-1;
+# argument: database release date format (yyyymmdd)
+# y = 0000 -> unkown
+# y = 9999 -> TBA
+# m = 99 -> month+day unkown
+# d = 99 -> day unknown
+# return value: (unknown|TBA|yyyy|yyyy-mm|yyyy-mm-dd)
+# if date > now: <b class="future">str</b>
+sub datestr {
+ my $date = sprintf '%08d', shift||0;
+ my $future = $date > strftime '%Y%m%d', gmtime;
+ my($y, $m, $d) = ($1, $2, $3) if $date =~ /^([0-9]{4})([0-9]{2})([0-9]{2})$/;
+
+ my $str = $y == 0 ? 'unknown' : $y == 9999 ? 'TBA' :
+ $m == 99 ? sprintf('%04d', $y) :
+ $d == 99 ? sprintf('%04d-%02d', $y, $m) :
+ sprintf('%04d-%02d-%02d', $y, $m, $d);
+
+ return $str if !$future;
+ return qq|<b class="future">$str</b>|;
+}
+
+
diff --git a/lib/VNDB/Handler/Producers.pm b/lib/VNDB/Handler/Producers.pm
index 2583ad13..d2bfa6db 100644
--- a/lib/VNDB/Handler/Producers.pm
+++ b/lib/VNDB/Handler/Producers.pm
@@ -4,6 +4,7 @@ package VNDB::Handler::Producers;
use strict;
use warnings;
use YAWF ':html';
+use VNDB::Func;
YAWF::register(
@@ -42,7 +43,9 @@ sub page {
ul;
for (@{$p->{vn}}) {
li;
- txt "$_->{date} ";
+ i;
+ lit datestr $_->{date};
+ end;
a href => "/v$_->{id}", title => $_->{original}, $_->{title};
end;
}