[Catalyst-commits] r14150 - in trunk/examples/CatalystAdvent:
lib/CatalystAdvent/Controller root
dhoss at dev.catalyst.perl.org
dhoss at dev.catalyst.perl.org
Thu Nov 10 23:06:33 GMT 2011
Author: dhoss
Date: 2011-11-10 23:06:33 +0000 (Thu, 10 Nov 2011)
New Revision: 14150
Modified:
trunk/examples/CatalystAdvent/lib/CatalystAdvent/Controller/Calendar.pm
trunk/examples/CatalystAdvent/root/wrapper.tt
Log:
got calculation working
Modified: trunk/examples/CatalystAdvent/lib/CatalystAdvent/Controller/Calendar.pm
===================================================================
--- trunk/examples/CatalystAdvent/lib/CatalystAdvent/Controller/Calendar.pm 2011-11-10 23:06:28 UTC (rev 14149)
+++ trunk/examples/CatalystAdvent/lib/CatalystAdvent/Controller/Calendar.pm 2011-11-10 23:06:33 UTC (rev 14150)
@@ -43,6 +43,12 @@
sub index : Chained('base') PathPart('') Args(0) {
my ( $self, $c ) = @_;
+ my $now = $c->stash->{now};
+ my $start_date = $now->clone->set( month => 12, day => 1 );
+ my $until = $start_date - $now;
+ $c->stash(
+ days_until => $until->delta_days
+ );
opendir DIR, $c->path_to('root') or die "Error opening root: $!";
my @years = sort grep { /\d{4}/ } readdir DIR;
closedir DIR;
Modified: trunk/examples/CatalystAdvent/root/wrapper.tt
===================================================================
--- trunk/examples/CatalystAdvent/root/wrapper.tt 2011-11-10 23:06:28 UTC (rev 14149)
+++ trunk/examples/CatalystAdvent/root/wrapper.tt 2011-11-10 23:06:33 UTC (rev 14150)
@@ -16,7 +16,10 @@
<p id="note">25 days of Catalyst tips!</p>
[% END %]
<div id="content">
+[%- IF days_until > 0; days_until %] days until the calendar starts!
+[% ELSE %]
[% content %]
+[% END %]
</div>
</div>
</body>
More information about the Catalyst-commits
mailing list