App-Oozie

 view release on metacpan or  search on metacpan

lib/App/Oozie/Date.pm  view on Meta::CPAN

package App::Oozie::Date;

use 5.014;
use strict;
use warnings;

our $VERSION = '0.020'; # VERSION

use namespace::autoclean -except => [qw/_options_data _options_config/];

use App::Oozie::Constants qw(
    DATE_PATTERN
    SHORTCUT_METHODS
);
use Carp qw( croak );
use DateTime;
use DateTime::Format::Strptime;
use DateTime::Format::Duration;
use Moo;
use Types::Standard qw( Str );

has strp => (
    is      => 'ro',
    default => sub {
        my $self = shift;
        DateTime::Format::Strptime->new(
                pattern   => DATE_PATTERN,
                time_zone => $self->timezone,
                on_error  => 'croak',
            );
    },
    lazy => 1,
);

has strp_silent => (
    is      => 'ro',
    default => sub {
        my $self = shift;
        DateTime::Format::Strptime->new(
                pattern   => DATE_PATTERN,
                time_zone => $self->timezone,
            );
    },
    lazy => 1,
);

has timezone => (
    is       => 'rw',
    isa      => Str,
    required => 1,
);

sub today {
    my $self  = shift;
    return $self->_stringify_dt( DateTime->today );
}

sub tomorrow {
    my $self  = shift;
    my $today = DateTime->today;
    $today->add( days => 1 );
    return $self->_stringify_dt( $today );
}

sub yesterday {
    my $self  = shift;
    my $today = DateTime->today;
    $today->subtract( days => 1 );
    return $self->_stringify_dt( $today );



( run in 0.510 second using v1.01-cache-2.11-cpan-56fb94df46f )