line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Yahoo::Marketing::DateTimeAccessor; |
2
|
|
|
|
|
|
|
# Copyright (c) 2009 Yahoo! Inc. All rights reserved. |
3
|
|
|
|
|
|
|
# The copyrights to the contents of this file are licensed under the Perl Artistic License (ver. 15 Aug 1997) |
4
|
|
|
|
|
|
|
|
5
|
165
|
|
|
165
|
|
1606
|
use strict; use warnings; |
|
165
|
|
|
165
|
|
1594
|
|
|
165
|
|
|
|
|
5624
|
|
|
165
|
|
|
|
|
861
|
|
|
165
|
|
|
|
|
314
|
|
|
165
|
|
|
|
|
5047
|
|
6
|
165
|
|
|
165
|
|
1782
|
use base qw/ Class::Accessor::Chained /; |
|
165
|
|
|
|
|
293
|
|
|
165
|
|
|
|
|
147165
|
|
7
|
|
|
|
|
|
|
|
8
|
165
|
|
|
165
|
|
756309
|
use DateTime::Format::W3CDTF; |
|
165
|
|
|
|
|
43798707
|
|
|
165
|
|
|
|
|
6017
|
|
9
|
165
|
|
|
165
|
|
186565
|
use DateTime::Format::ISO8601; |
|
165
|
|
|
|
|
11999784
|
|
|
165
|
|
|
|
|
66598
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub _force_datetime_object { |
12
|
0
|
|
|
0
|
|
|
my ( $self, $value ) = @_; |
13
|
|
|
|
|
|
|
|
14
|
0
|
0
|
|
|
|
|
if( defined $value ){ |
15
|
0
|
0
|
|
|
|
|
unless( ref $value ){ # not a date time object |
16
|
0
|
|
|
|
|
|
$value = DateTime::Format::ISO8601->new->parse_datetime( $value ); |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
# let's hope it looks like a duck... er, DateTime object |
19
|
0
|
|
|
|
|
|
$value->set_formatter( DateTime::Format::W3CDTF->new ); |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
0
|
|
|
|
|
|
return $value; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub set { |
26
|
0
|
|
|
0
|
1
|
|
my ( $self, $key, @values ) = @_; |
27
|
|
|
|
|
|
|
|
28
|
0
|
0
|
0
|
|
|
|
if ( $key =~ /Date$/ || $key =~ /Timestamp$/ ){ |
29
|
0
|
|
|
|
|
|
@values = map { $self->_force_datetime_object( $_ ) } @values; |
|
0
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
0
|
|
|
|
|
|
$self->SUPER::set( $key, @values ); |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
1; |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
__END__ |