#!/usr/bin/perl -- use strict; use warnings; use Time::Piece; use Time::Seconds(); use Mojolicious::Lite; ## flips on strict/warnings sub date_time_mojo { my $self = shift; my $dir = $self->param('dir'); my $today = $self->param('today'); my $thismonth = $self->param('thismonth'); my $thisyear = $self->param('thisyear'); my $time ; if( $dir and $today and $thismonth ){ $time = Time::Piece->strptime("$today $thismonth $thisyear", '%d %m %Y'); if( lc $dir eq 'yesterday'){ $time -= Time::Seconds::ONE_DAY() ; } else { $time += Time::Seconds::ONE_DAY() ; } } else { $time = gmtime; } $self->render( t => $time, title => $time->ymd, ); } get '/' => \&date_time_mojo => 'index';; app->start; __DATA__ @@ index.html.ep % layout 'green'; %= content content => begin <%== $t->ymd %>
% end @@ layouts/green.html.ep <%== title %> <%= content %> #### $ perl fudge get / [Fri Jun 7 01:31:06 2013] [debug] Your secret passphrase needs to be changed!!! [Fri Jun 7 01:31:06 2013] [debug] GET / (Mojolicious (Perl)). [Fri Jun 7 01:31:06 2013] [debug] Routing to a callback. [Fri Jun 7 01:31:06 2013] [debug] Rendering template "index.html.ep" from DATA section. [Fri Jun 7 01:31:06 2013] [debug] Rendering template "layouts/green.html.ep" from DATA section. [Fri Jun 7 01:31:06 2013] [debug] 200 OK (0.055773s, 17.930/s). 2013-06-07 2013-06-07
##
## $ perl fudge get /?today=7;thismonth=6;thisyear=2013;dir=Tomorrow [Fri Jun 7 01:32:20 2013] [debug] Your secret passphrase needs to be changed!!! [Fri Jun 7 01:32:20 2013] [debug] GET / (Mojolicious (Perl)). [Fri Jun 7 01:32:20 2013] [debug] Routing to a callback. [Fri Jun 7 01:32:20 2013] [debug] Rendering template "index.html.ep" from DATA section. [Fri Jun 7 01:32:20 2013] [debug] Rendering template "layouts/green.html.ep" from DATA section. [Fri Jun 7 01:32:20 2013] [debug] 200 OK (0.058046s, 17.228/s). 2013-06-08 2013-06-08