line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Eve::PgSqlType::TimestampWithTimeZone; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
203800
|
use parent qw(Eve::PgSqlType); |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
8
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
use strict; |
6
|
|
|
|
|
|
|
use warnings; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
use DateTime::Format::Pg; |
9
|
|
|
|
|
|
|
use DBD::Pg (); |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 NAME |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
B - a PostgreSQL timestamp |
14
|
|
|
|
|
|
|
with timezone type. |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=head1 SYNOPSIS |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
my $bigint = Eve::PgSqlType::TimestampWithTimeZone->new(); |
19
|
|
|
|
|
|
|
$bigint->serialize(value => $datetime); |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=head1 DESCRIPTION |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
B is a PostgreSQL timestamp |
24
|
|
|
|
|
|
|
with time zone type adapter class. |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=head1 METHODS |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=head2 B |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=head3 Returns |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
The PG_TIMESTAMPTZ type. |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=cut |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub get_type { |
37
|
|
|
|
|
|
|
return DBD::Pg::PG_TIMESTAMPTZ; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=head2 B |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
Wraps an expression with CAST statement. |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=head3 Arguments |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=over 4 |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=item C |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=back |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=head3 Returns |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
CAST (C AS timestamp with time zone) |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=cut |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub wrap { |
59
|
|
|
|
|
|
|
my ($self, %arg_hash) = @_; |
60
|
|
|
|
|
|
|
Eve::Support::arguments(\%arg_hash, my $expression); |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
return 'CAST ('.$expression.' AS timestamp with time zone)'; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=head2 B |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
Formats a B object into the appropriate string timestamp |
68
|
|
|
|
|
|
|
with timezone representation with the B module. |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=head3 Arguments |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=over 4 |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=item C |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=back |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=head3 Returns |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
The string like '2011-03-21 20:41:34.123456+03'. |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=cut |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
sub serialize { |
85
|
|
|
|
|
|
|
my ($self, %arg_hash) = @_; |
86
|
|
|
|
|
|
|
Eve::Support::arguments(\%arg_hash, my $value); |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
if (not defined $value) { |
89
|
|
|
|
|
|
|
return 'NULL'; |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
return DateTime::Format::Pg->format_timestamp_with_time_zone($value); |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=head2 B |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
Parces a timestamp with time zone string representation into the |
98
|
|
|
|
|
|
|
appropriate B object with the B |
99
|
|
|
|
|
|
|
module. |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=head3 Arguments |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=over 4 |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=item C |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=back |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=head3 Returns |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
A B object. |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=cut |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
sub deserialize { |
116
|
|
|
|
|
|
|
my ($self, %arg_hash) = @_; |
117
|
|
|
|
|
|
|
Eve::Support::arguments(\%arg_hash, my $value); |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
my $result; |
120
|
|
|
|
|
|
|
if (defined $value) { |
121
|
|
|
|
|
|
|
$result = DateTime::Format::Pg->parse_timestamp_with_time_zone($value); |
122
|
|
|
|
|
|
|
} |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
return $result; |
125
|
|
|
|
|
|
|
} |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=head1 SEE ALSO |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=over 4 |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=item L |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=item L |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=item L |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=item L |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=back |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
Copyright 2012 Igor Zinovyev. |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
146
|
|
|
|
|
|
|
under the terms of either: the GNU General Public License as published |
147
|
|
|
|
|
|
|
by the Free Software Foundation; or the Artistic License. |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
See http://dev.perl.org/licenses/ for more information. |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
=head1 AUTHOR |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
=over 4 |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
=item L |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
=back |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
=cut |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
1; |