| 1 | package Mojolicious::Plugin::DateTime; | ||
| 2 | 2 | ▶ | use Mojo::Base 'Mojolicious::Plugin'; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 3 | # ABSTRACT: Mojolicious plugin to DateTime module integration | ||
| 4 | |||
| 5 | 2 | our $VERSION = '0.02'; | |
| 6 | |||
| 7 | 2 | ▶ | use DateTime; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 8 | |||
| 9 | 1 | ▶ | sub register { |
|
Subroutine
register: called CC=1 SCAR=0.0
Pod
documented
| |||
| 10 | 1 | my ( $self, $app ) = @_; | |
| 11 | |||
| 12 | # datetime method helper | ||
| 13 | $app->helper( | ||
| 14 | 3 | ▶ | datetime => sub { |
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||
| 15 | 3 | my $self = shift; | |
| 16 | 3 | return DateTime->new(@_); | |
| 17 | } | ||
| 18 | 1 | ); | |
| 19 | |||
| 20 | # datetime short way | ||
| 21 | $app->helper( | ||
| 22 | 1 | ▶ | dt => sub { |
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||
| 23 | 1 | return shift->datetime(@_); | |
| 24 | } | ||
| 25 | 1 | ); | |
| 26 | |||
| 27 | # datetime now method call | ||
| 28 | $app->helper( | ||
| 29 | 1 | ▶ | now => sub { |
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||
| 30 | 1 | my $self = shift; | |
| 31 | 1 | return DateTime->now(@_); | |
| 32 | } | ||
| 33 | ) | ||
| 34 | |||
| 35 | 1 | } | |
| 36 | |||
| 37 | 2 | 1; | |
| 38 | |||
| 39 | __END__ | ||