#!/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 %>