App-CamelPKI

 view release on metacpan or  search on metacpan

lib/App/CamelPKI/Time.pm  view on Meta::CPAN

    my $dt = $self->{dt}->clone;
    my $duration = DateTime::Duration->new(years => abs($days));
    $days >= 0 ? $dt->add_duration($duration) :
        $dt->subtract_duration($duration);
    return bless { dt => $dt }, ref($self);
}

=head2 make_your()

Nothing, actually.

=cut

sub make_your {
    die "ALL YOUR CODEBASE ARE BELONG TO US";
}

require My::Tests::Below unless caller;
1;

__END__

=begin internals

=head1 TESTS

=cut

use Test::More qw(no_plan);
use Test::Group;

test "now() and stringification" => sub {
    like(App::CamelPKI::Time->now(), qr/^\d{14}Z$/);
};

test "->parse" => sub {
    like(App::CamelPKI::Time->parse("now"), qr/^\d{14}Z$/);
};

test "overload and compare" => sub {
    my $time = App::CamelPKI::Time->now();
    sleep(2);
    cmp_ok($time, "lt", App::CamelPKI::Time->now());
};

test "->parse(\$object) does a copy" => sub {
    my $time = App::CamelPKI::Time->now();
    my $time2 = App::CamelPKI::Time->parse($time);
    is($time->zulu, $time2->zulu, "same hour...");
    ok(! ($time == $time2), "... but different address");
    cmp_ok($time, "eq", $time2, "string comparison works");
};

test "synopsis" => sub {
    my $code = My::Tests::Below->pod_code_snippet("synopsis");
    $code =~ s/print//g;
    $code =~ s/my //g;
    my ($time, $later);
    eval $code; die $@ if $@;

    is("$later", "20070524101200Z");
};

test "->advance_days and ->advance_years" => sub {
    my $date = App::CamelPKI::Time->now;
    ok( ($date->advance_days(365)->zulu eq $date->advance_years(1)->zulu)
       or
        ($date->advance_days(366)->zulu eq $date->advance_years(1)->zulu) );
};

=end internals

=cut



( run in 0.650 second using v1.01-cache-2.11-cpan-39bf76dae61 )