| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Rose::DB::Object::Metadata::Column::Date; |
|
2
|
|
|
|
|
|
|
|
|
3
|
4
|
|
|
4
|
|
29
|
use strict; |
|
|
4
|
|
|
|
|
10
|
|
|
|
4
|
|
|
|
|
140
|
|
|
4
|
|
|
|
|
|
|
|
|
5
|
4
|
|
|
4
|
|
23
|
use Rose::DateTime::Util(); |
|
|
4
|
|
|
|
|
7
|
|
|
|
4
|
|
|
|
|
86
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
4
|
|
|
4
|
|
22
|
use Rose::Object::MakeMethods::Generic; |
|
|
4
|
|
|
|
|
8
|
|
|
|
4
|
|
|
|
|
29
|
|
|
8
|
4
|
|
|
4
|
|
3115
|
use Rose::DB::Object::MakeMethods::Date; |
|
|
4
|
|
|
|
|
11
|
|
|
|
4
|
|
|
|
|
50
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
4
|
|
|
4
|
|
149
|
use Rose::DB::Object::Metadata::Column; |
|
|
4
|
|
|
|
|
12
|
|
|
|
4
|
|
|
|
|
541
|
|
|
11
|
|
|
|
|
|
|
our @ISA = qw(Rose::DB::Object::Metadata::Column); |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our $VERSION = '0.788'; |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
__PACKAGE__->add_common_method_maker_argument_names('default', 'time_zone', 'type'); |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
Rose::Object::MakeMethods::Generic->make_methods |
|
18
|
|
|
|
|
|
|
( |
|
19
|
|
|
|
|
|
|
{ preserve_existing => 1 }, |
|
20
|
|
|
|
|
|
|
scalar => [ __PACKAGE__->common_method_maker_argument_names ] |
|
21
|
|
|
|
|
|
|
); |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
foreach my $type (__PACKAGE__->available_method_types) |
|
24
|
|
|
|
|
|
|
{ |
|
25
|
|
|
|
|
|
|
__PACKAGE__->method_maker_class($type => 'Rose::DB::Object::MakeMethods::Date'); |
|
26
|
|
|
|
|
|
|
__PACKAGE__->method_maker_type($type => 'date'); |
|
27
|
|
|
|
|
|
|
} |
|
28
|
|
|
|
|
|
|
|
|
29
|
10
|
|
|
10
|
1
|
64
|
sub type { 'date' } |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub should_inline_value |
|
32
|
|
|
|
|
|
|
{ |
|
33
|
0
|
|
|
0
|
1
|
0
|
my($self, $db, $value) = @_; |
|
34
|
4
|
|
|
4
|
|
28
|
no warnings 'uninitialized'; |
|
|
4
|
|
|
|
|
10
|
|
|
|
4
|
|
|
|
|
1870
|
|
|
35
|
0
|
0
|
0
|
|
|
0
|
return (($db->validate_date_keyword($value) && $db->should_inline_date_keyword($value)) || |
|
36
|
|
|
|
|
|
|
($db->keyword_function_calls && $value =~ /^\w+\(.*\)$/)) ? 1 : 0; |
|
37
|
|
|
|
|
|
|
} |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub method_should_set |
|
40
|
|
|
|
|
|
|
{ |
|
41
|
0
|
|
|
0
|
0
|
0
|
my($self, $type, $args) = @_; |
|
42
|
|
|
|
|
|
|
|
|
43
|
0
|
0
|
|
|
|
0
|
return 1 if($type eq 'set'); |
|
44
|
0
|
0
|
|
|
|
0
|
return 0 if($type eq 'get'); |
|
45
|
|
|
|
|
|
|
|
|
46
|
0
|
0
|
|
|
|
0
|
if($type eq 'get_set') |
|
47
|
|
|
|
|
|
|
{ |
|
48
|
|
|
|
|
|
|
# Set with 1 arg, but two args is a form of get. |
|
49
|
|
|
|
|
|
|
# Three or more args is undefined... |
|
50
|
0
|
0
|
|
|
|
0
|
return @$args == 2 ? 1 : 0; |
|
51
|
|
|
|
|
|
|
} |
|
52
|
|
|
|
|
|
|
|
|
53
|
0
|
|
|
|
|
0
|
return $self->SUPER::method_should_set($type, $args); |
|
54
|
|
|
|
|
|
|
} |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub parse_value |
|
57
|
|
|
|
|
|
|
{ |
|
58
|
0
|
|
|
0
|
1
|
0
|
my($self, $db) = (shift, shift); |
|
59
|
|
|
|
|
|
|
|
|
60
|
0
|
|
|
|
|
0
|
$self->parse_error(undef); |
|
61
|
|
|
|
|
|
|
|
|
62
|
0
|
|
|
|
|
0
|
my $dt = $db->parse_date(@_); |
|
63
|
|
|
|
|
|
|
|
|
64
|
0
|
0
|
|
|
|
0
|
if($dt) |
|
65
|
|
|
|
|
|
|
{ |
|
66
|
0
|
0
|
0
|
|
|
0
|
$dt->set_time_zone($self->time_zone || $db->server_time_zone) |
|
67
|
|
|
|
|
|
|
if(UNIVERSAL::isa($dt, 'DateTime')); |
|
68
|
|
|
|
|
|
|
} |
|
69
|
|
|
|
|
|
|
else |
|
70
|
|
|
|
|
|
|
{ |
|
71
|
0
|
|
0
|
|
|
0
|
$dt = Rose::DateTime::Util::parse_date($_[0], $self->time_zone || $db->server_time_zone); |
|
72
|
|
|
|
|
|
|
|
|
73
|
0
|
0
|
|
|
|
0
|
if(my $error = Rose::DateTime::Util->error) |
|
74
|
|
|
|
|
|
|
{ |
|
75
|
0
|
0
|
|
|
|
0
|
$self->parse_error("Could not parse value '$_[0]' for column $self: $error") |
|
76
|
|
|
|
|
|
|
if(defined $_[0]); |
|
77
|
|
|
|
|
|
|
} |
|
78
|
|
|
|
|
|
|
} |
|
79
|
|
|
|
|
|
|
|
|
80
|
0
|
|
|
|
|
0
|
return $dt; |
|
81
|
|
|
|
|
|
|
} |
|
82
|
|
|
|
|
|
|
|
|
83
|
0
|
|
|
0
|
1
|
0
|
sub format_value { shift; shift->format_date(@_) } |
|
|
0
|
|
|
|
|
0
|
|
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
sub method_uses_formatted_key |
|
86
|
|
|
|
|
|
|
{ |
|
87
|
4
|
|
|
4
|
0
|
14
|
my($self, $type) = @_; |
|
88
|
4
|
50
|
33
|
|
|
31
|
return 1 if($type eq 'get' || $type eq 'set' || $type eq 'get_set'); |
|
|
|
|
33
|
|
|
|
|
|
89
|
0
|
|
|
|
|
|
return 0; |
|
90
|
|
|
|
|
|
|
} |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
1; |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
__END__ |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=head1 NAME |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
Rose::DB::Object::Metadata::Column::Date - Date column metadata. |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
use Rose::DB::Object::Metadata::Column::Date; |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
$col = Rose::DB::Object::Metadata::Column::Date->new(...); |
|
105
|
|
|
|
|
|
|
$col->make_methods(...); |
|
106
|
|
|
|
|
|
|
... |
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
Objects of this class store and manipulate metadata for date 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. |
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
This class inherits from L<Rose::DB::Object::Metadata::Column>. Inherited methods that are not overridden will not be documented a second time here. See the L<Rose::DB::Object::Metadata::Column> documentation for more information. |
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=head1 METHOD MAP |
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=over 4 |
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=item C<get_set> |
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
L<Rose::DB::Object::MakeMethods::Date>, L<date|Rose::DB::Object::MakeMethods::Date/date>, C<interface =E<gt> 'get_set', ...> |
|
121
|
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=item C<get> |
|
123
|
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
L<Rose::DB::Object::MakeMethods::Date>, L<date|Rose::DB::Object::MakeMethods::Date/date>, C<interface =E<gt> 'get', ...> |
|
125
|
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=item C<set> |
|
127
|
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
L<Rose::DB::Object::MakeMethods::Date>, L<date|Rose::DB::Object::MakeMethods::Date/date>, C<interface =E<gt> 'set', ...> |
|
129
|
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=back |
|
131
|
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
See the L<Rose::DB::Object::Metadata::Column|Rose::DB::Object::Metadata::Column/"MAKING METHODS"> documentation for an explanation of this method map. |
|
133
|
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=head1 OBJECT METHODS |
|
135
|
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
=over 4 |
|
137
|
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
=item B<parse_value DB, VALUE> |
|
139
|
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
Convert VALUE to the equivalent L<DateTime> object. VALUE maybe returned unmodified if it is a valid date 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. |
|
141
|
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
=item B<time_zone [TZ]> |
|
143
|
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
Get or set the time zone of the dates stored in this column. TZ should be a time zone name that is understood by L<DateTime::TimeZone>. |
|
145
|
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=item B<type> |
|
147
|
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
Returns "date". |
|
149
|
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
=back |
|
151
|
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
=head1 AUTHOR |
|
153
|
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
John C. Siracusa (siracusa@gmail.com) |
|
155
|
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
=head1 LICENSE |
|
157
|
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
Copyright (c) 2010 by John C. Siracusa. All rights reserved. This program is |
|
159
|
|
|
|
|
|
|
free software; you can redistribute it and/or modify it under the same terms |
|
160
|
|
|
|
|
|
|
as Perl itself. |