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   3511 use Moo::Role;
  6         18  
  6         47  
4              
5 6     6   1912 use namespace::autoclean;
  6         25  
  6         41  
6              
7             our $VERSION = '0.000027';
8              
9 6     6   584 use feature qw( state );
  6         15  
  6         710  
10              
11 6     6   1342 use DateTime::TimeZone;
  6         287209  
  6         229  
12 6     6   2109 use DateTime::Format::MySQL;
  6         940319  
  6         285  
13 6     6   61 use Types::Standard qw( InstanceOf Maybe );
  6         18  
  6         89  
14              
15             has transaction_time => (
16             is => 'lazy',
17             isa => Maybe [ InstanceOf ['DateTime'] ],
18             );
19              
20             sub _build_transaction_time {
21 18     18   10447 my $self = shift;
22              
23 18         76 state $time_zone
24             = DateTime::TimeZone->new( name => 'America/Los_Angeles' );
25              
26 18 100       16170 return undef unless my $transtime = $self->params->{TRANSTIME};
27              
28 17         99 my $dt = DateTime::Format::MySQL->parse_datetime($transtime);
29 17         7893 $dt->set_time_zone($time_zone);
30 17         5701 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.000027
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) 2021 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