line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
1
|
|
|
1
|
|
106270
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
43
|
|
2
|
1
|
|
|
1
|
|
7
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
31
|
|
3
|
|
|
|
|
|
|
|
4
|
1
|
|
|
1
|
|
29
|
use 5.006; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
84
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
package DateTime::Format::PayPal::IPN; |
7
|
|
|
|
|
|
|
$DateTime::Format::PayPal::IPN::VERSION = '0.000001'; |
8
|
1
|
|
|
1
|
|
7
|
use Carp qw( croak ); |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
66
|
|
9
|
1
|
|
|
1
|
|
1004
|
use DateTime::TimeZone; |
|
1
|
|
|
|
|
101693
|
|
|
1
|
|
|
|
|
30
|
|
10
|
1
|
|
|
1
|
|
1199
|
use DateTime::Format::Strptime; |
|
1
|
|
|
|
|
131214
|
|
|
1
|
|
|
|
|
300
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
my $pattern = '%H:%M:%S %b %d, %Y'; |
13
|
|
|
|
|
|
|
my $tz = DateTime::TimeZone->new( name => 'America/Los_Angeles' ); |
14
|
|
|
|
|
|
|
my $strp = DateTime::Format::Strptime->new( |
15
|
|
|
|
|
|
|
pattern => $pattern, |
16
|
|
|
|
|
|
|
time_zone => $tz, |
17
|
|
|
|
|
|
|
); |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub parse_timestamp { |
20
|
1
|
|
|
1
|
1
|
17
|
my $class = shift; |
21
|
1
|
|
|
|
|
3
|
my $date = shift; |
22
|
|
|
|
|
|
|
|
23
|
1
|
|
|
|
|
2
|
my $orig = $date; |
24
|
1
|
|
|
|
|
10
|
$date =~ s{ (PST|PDT)\z}{}; |
25
|
|
|
|
|
|
|
|
26
|
1
|
|
|
|
|
9
|
my $dt = $strp->parse_datetime( $date ); |
27
|
1
|
50
|
|
|
|
1470
|
croak 'could not parse string: ' . $orig unless $dt; |
28
|
|
|
|
|
|
|
|
29
|
1
|
|
|
|
|
49
|
return $dt; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub format_timestamp { |
33
|
1
|
|
|
1
|
1
|
571
|
my $class = shift; |
34
|
1
|
|
|
|
|
3
|
my $dt = shift; |
35
|
|
|
|
|
|
|
|
36
|
1
|
|
|
|
|
5
|
my $stamp = $dt->strftime( $pattern, $dt ); |
37
|
1
|
50
|
|
|
|
115
|
$stamp .= $dt->is_dst ? ' PDT' : ' PST'; |
38
|
1
|
|
|
|
|
196
|
return $stamp; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
1; |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=pod |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=encoding UTF-8 |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=head1 NAME |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
DateTime::Format::PayPal::IPN - Parse PayPal IPN timestamps |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=head1 VERSION |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
version 0.000001 |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=head1 SYNOPSIS |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
use DateTime::Format::PayPal::IPN; |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
my $dt = DateTime::Format::PayPal::IPN->parse_timestamp( '02:35:35 Feb 16, 2010 PST' ); |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
# 2010-02-16 02:35:35 |
62
|
|
|
|
|
|
|
DateTime::Format::PayPal::IPN->format_timestamp($dt); |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=head1 DESCRIPTION |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
This module parses and formats timestamps returned by PayPal's IPN (Instant |
67
|
|
|
|
|
|
|
Payment Notification) system. |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=head1 METHODS |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=over 4 |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=item * parse_timestamp($string) |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
Given a value of the appropriate type, this method will return a new |
76
|
|
|
|
|
|
|
L object. The time zone for this object will always be the |
77
|
|
|
|
|
|
|
'America/Los_Angeles' as all IPN data which I have seen is sent in this time |
78
|
|
|
|
|
|
|
zone format. |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
If given an improperly formatted string, this method should die. |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=item * format_timestamp($datetime) |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
Given a C object, this methods returns an appropriately |
85
|
|
|
|
|
|
|
formatted string. |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=back |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
Most of the Pod was directly lifted from Dave Rolsky's L. |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=head1 AUTHOR |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
Olaf Alders |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
This software is Copyright (c) 2014 by MaxMind, Inc. |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
This is free software, licensed under: |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
The Artistic License 2.0 (GPL Compatible) |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=cut |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
__END__ |