File Coverage

blib/lib/WebService/PayPal/PaymentsAdvanced/Role/HasTransactionTime.pm
Criterion Covered Total %
statement 24 24 100.0
branch 2 2 100.0
condition n/a
subroutine 7 7 100.0
pod n/a
total 33 33 100.0


line stmt bran cond sub pod time code
1             package WebService::PayPal::PaymentsAdvanced::Role::HasTransactionTime;
2              
3 6     6   3486 use Moo::Role;
  6         15  
  6         46  
4              
5 6     6   2051 use namespace::autoclean;
  6         32  
  6         67  
6              
7             our $VERSION = '0.000028';
8              
9 6     6   656 use feature qw( state );
  6         16  
  6         698  
10              
11 6     6   1193 use DateTime::TimeZone ();
  6         291572  
  6         173  
12 6     6   2024 use DateTime::Format::MySQL ();
  6         971439  
  6         261  
13 6     6   64 use Types::Standard qw( InstanceOf Maybe );
  6         43  
  6         159  
14              
15             has transaction_time => (
16             is => 'lazy',
17             isa => Maybe [ InstanceOf ['DateTime'] ],
18             );
19              
20             sub _build_transaction_time {
21 18     18   16787 my $self = shift;
22              
23 18         101 state $time_zone
24             = DateTime::TimeZone->new( name => 'America/Los_Angeles' );
25              
26 18 100       15940 return undef unless my $transtime = $self->params->{TRANSTIME};
27              
28 17         159 my $dt = DateTime::Format::MySQL->parse_datetime($transtime);
29 17         10729 $dt->set_time_zone($time_zone);
30 17         5857 return $dt;
31             }
32             1;
33              
34             =pod
35              
36             =encoding UTF-8
37              
38             =head1 NAME
39              
40             WebService::PayPal::PaymentsAdvanced::Role::HasTransactionTime - Role which converts TRANSTIME into a DateTime object
41              
42             =head1 VERSION
43              
44             version 0.000028
45              
46             =head2 transaction_time
47              
48             Returns C<TRANSTIME> in the form of a DateTime object
49              
50             =head1 SUPPORT
51              
52             Bugs may be submitted through L<https://github.com/maxmind/webservice-paypal-paymentsadvanced/issues>.
53              
54             =head1 AUTHOR
55              
56             Olaf Alders <olaf@wundercounter.com>
57              
58             =head1 COPYRIGHT AND LICENSE
59              
60             This software is copyright (c) 2022 by MaxMind, Inc.
61              
62             This is free software; you can redistribute it and/or modify it under
63             the same terms as the Perl 5 programming language system itself.
64              
65             =cut
66              
67             __END__
68              
69             # ABSTRACT: Role which converts TRANSTIME into a DateTime object
70