Ignore:
Timestamp:
01/28/16 16:34:17 (8 years ago)
Author:
nanardon
Message:

Add a default (funny) web page

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/LATMOS-Accounts-Web/lib/LATMOS/Accounts/Web/Controller/Root.pm

    r1682 r1687  
    66no utf8; 
    77use POSIX; 
     8use DateTime; 
     9use Date::Calc; 
     10use Date::Parse; 
    811 
    912# 
     
    6568 
    6669    $c->res->status(404);  
     70} 
     71 
     72sub index : Private { 
     73    my ( $self, $c ) = @_; 
     74 
     75    my $ouser = $c->model('Accounts')->db->get_object( 
     76        'user', 
     77        $c->user->{username}, 
     78    ); 
     79 
     80    my @cd = split('-', DateTime->from_epoch( 
     81        epoch => str2time( 
     82            $ouser->get_attributes('create'), 
     83        ) 
     84    )->ymd('-')); 
     85    my @now = split('-', DateTime->now()->ymd('-')); 
     86 
     87    my ($Dy,$Dm,$Dd) = Date::Calc::N_Delta_YMD(@cd, @now); 
     88    $c->stash->{accountExists} = join(', ', 
     89        ($Dy ? $c->loc('[_1] years', $Dy)  : ()), 
     90        ($Dm ? $c->loc('[_1] months', $Dm) : ()), 
     91        ($Dd ? $c->loc('[_1] days', $Dd)   : ()), 
     92    ); 
     93 
     94    if (my $expire = $ouser->get_attributes('expire')) { 
     95        my @ed = split('-', DateTime->from_epoch( 
     96            epoch => str2time( 
     97                $expire 
     98            ) 
     99        )->ymd('-')); 
     100 
     101        my ($Dy,$Dm,$Dd) = Date::Calc::N_Delta_YMD(@now, @ed); 
     102        $c->stash->{accountExpire} = join(', ', 
     103            ($Dy ? $c->loc('[_1] years', $Dy)  : ()), 
     104            ($Dm ? $c->loc('[_1] months', $Dm) : ()), 
     105            ($Dd ? $c->loc('[_1] days', $Dd)   : ()), 
     106        ); 
     107    } 
     108 
     109 
    67110} 
    68111 
Note: See TracChangeset for help on using the changeset viewer.