line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Rose::DB::Object::Metadata::Column::Timestamp; |
2
|
|
|
|
|
|
|
|
3
|
4
|
|
|
4
|
|
29
|
use strict; |
|
4
|
|
|
|
|
16
|
|
|
4
|
|
|
|
|
127
|
|
4
|
|
|
|
|
|
|
|
5
|
4
|
|
|
4
|
|
22
|
use Rose::DateTime::Util; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
225
|
|
6
|
4
|
|
|
4
|
|
25
|
use Rose::DB::Object::MakeMethods::Date; |
|
4
|
|
|
|
|
13
|
|
|
4
|
|
|
|
|
30
|
|
7
|
|
|
|
|
|
|
|
8
|
4
|
|
|
4
|
|
90
|
use Rose::DB::Object::Metadata::Column::Date; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
582
|
|
9
|
|
|
|
|
|
|
our @ISA = qw(Rose::DB::Object::Metadata::Column::Date); |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $VERSION = '0.788'; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
foreach my $type (__PACKAGE__->available_method_types) |
14
|
|
|
|
|
|
|
{ |
15
|
|
|
|
|
|
|
__PACKAGE__->method_maker_type($type => 'timestamp'); |
16
|
|
|
|
|
|
|
} |
17
|
|
|
|
|
|
|
|
18
|
9
|
|
|
9
|
1
|
70
|
sub type { 'timestamp' } |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub should_inline_value |
21
|
|
|
|
|
|
|
{ |
22
|
0
|
|
|
0
|
1
|
|
my($self, $db, $value) = @_; |
23
|
4
|
|
|
4
|
|
38
|
no warnings 'uninitialized'; |
|
4
|
|
|
|
|
15
|
|
|
4
|
|
|
|
|
1362
|
|
24
|
0
|
0
|
0
|
|
|
|
return (($db->validate_timestamp_keyword($value) && $db->should_inline_timestamp_keyword($value)) || |
25
|
|
|
|
|
|
|
($db->keyword_function_calls && $value =~ /^\w+\(.*\)$/)) ? 1 : 0; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub parse_value |
29
|
|
|
|
|
|
|
{ |
30
|
0
|
|
|
0
|
1
|
|
my($self, $db) = (shift, shift); |
31
|
|
|
|
|
|
|
|
32
|
0
|
|
|
|
|
|
$self->parse_error(undef); |
33
|
|
|
|
|
|
|
|
34
|
0
|
|
|
|
|
|
my $dt = $db->parse_timestamp(@_); |
35
|
|
|
|
|
|
|
|
36
|
0
|
0
|
|
|
|
|
if($dt) |
37
|
|
|
|
|
|
|
{ |
38
|
0
|
0
|
0
|
|
|
|
$dt->set_time_zone($self->time_zone || $db->server_time_zone) |
39
|
|
|
|
|
|
|
if(UNIVERSAL::isa($dt, 'DateTime')); |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
else |
42
|
|
|
|
|
|
|
{ |
43
|
0
|
|
0
|
|
|
|
$dt = Rose::DateTime::Util::parse_date($_[0], $self->time_zone || $db->server_time_zone); |
44
|
|
|
|
|
|
|
|
45
|
0
|
0
|
|
|
|
|
if(my $error = Rose::DateTime::Util->error) |
46
|
|
|
|
|
|
|
{ |
47
|
0
|
0
|
|
|
|
|
$self->parse_error("Could not parse value '$_[0]' for column $self: $error") |
48
|
|
|
|
|
|
|
if(defined $_[0]); |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
0
|
|
|
|
|
|
return $dt; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
0
|
|
|
0
|
1
|
|
sub format_value { shift; shift->format_timestamp(@_) } |
|
0
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
1; |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
__END__ |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=head1 NAME |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
Rose::DB::Object::Metadata::Column::Timestamp - Timestamp column metadata. |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=head1 SYNOPSIS |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
use Rose::DB::Object::Metadata::Column::Timestamp; |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
$col = Rose::DB::Object::Metadata::Column::Timestamp->new(...); |
70
|
|
|
|
|
|
|
$col->make_methods(...); |
71
|
|
|
|
|
|
|
... |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=head1 DESCRIPTION |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
Objects of this class store and manipulate metadata for timestamp columns in a database. Column metadata objects store information about columns (data type, size, etc.) and are responsible for creating object methods that manipulate column values. |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
This class inherits from L<Rose::DB::Object::Metadata::Column::Date>. Inherited methods that are not overridden will not be documented a second time here. See the L<Rose::DB::Object::Metadata::Column::Date> documentation for more information. |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=head1 METHOD MAP |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=over 4 |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=item C<get_set> |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
L<Rose::DB::Object::MakeMethods::Date>, L<timestamp|Rose::DB::Object::MakeMethods::Date/timestamp>, C<interface =E<gt> 'get_set', ...> |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=item C<get> |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
L<Rose::DB::Object::MakeMethods::Date>, L<timestamp|Rose::DB::Object::MakeMethods::Date/timestamp>, C<interface =E<gt> 'get', ...> |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=item C<set> |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
L<Rose::DB::Object::MakeMethods::Date>, L<timestamp|Rose::DB::Object::MakeMethods::Date/timestamp>, C<interface =E<gt> 'set', ...> |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=back |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
See the L<Rose::DB::Object::Metadata::Column|Rose::DB::Object::Metadata::Column/"MAKING METHODS"> documentation for an explanation of this method map. |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=head1 OBJECT METHODS |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=over 4 |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=item B<parse_value DB, VALUE> |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
Convert VALUE to the equivalent C<DateTime> object. VALUE maybe returned unmodified if it is a valid timestamp keyword or otherwise has special meaning to the underlying database. DB is a L<Rose::DB> object that is used as part of the parsing process. Both arguments are required. |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=item B<type> |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
Returns "timestamp". |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=back |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=head1 AUTHOR |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
John C. Siracusa (siracusa@gmail.com) |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=head1 LICENSE |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
Copyright (c) 2010 by John C. Siracusa. All rights reserved. This program is |
120
|
|
|
|
|
|
|
free software; you can redistribute it and/or modify it under the same terms |
121
|
|
|
|
|
|
|
as Perl itself. |