From 8209ca6017e5ccff8cc0597eab03dc6ffc2ed599 Mon Sep 17 00:00:00 2001 From: Yorhel Date: Wed, 12 Nov 2008 15:02:42 +0100 Subject: Added datestr() and fixed the release date display on producer pages --- lib/VNDB/Func.pm | 25 +++++++++++++++++++++++-- lib/VNDB/Handler/Producers.pm | 5 ++++- static/f/style.css | 11 +++++++++-- 3 files changed, 36 insertions(+), 5 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: str +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|$str|; +} + + 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; } diff --git a/static/f/style.css b/static/f/style.css index 52701306..06f65e37 100644 --- a/static/f/style.css +++ b/static/f/style.css @@ -163,6 +163,10 @@ td.field label { p.center { text-align: center; } +b.future { + font-weight: normal; + color: #e44; +} @@ -348,8 +352,11 @@ div.vndescription p { padding-top: 3px; list-style-type: none; } -.producerpage li a { - margin-left: 10px; +.producerpage li i { + display: block; + font-style: normal; + float: left; + width: 80px; } -- cgit v1.2.3