| 1 | package Rose::DB::Object::Metadata::Column::TimestampWithTimeZone; | ||
| 2 | |||
| 3 | use strict; | ||
| 4 | |||
| 5 | use Rose::DB::Object::Metadata::Column::Timestamp; | ||
| 6 | our @ISA = qw(Rose::DB::Object::Metadata::Column::Timestamp); | ||
| 7 | |||
| 8 | our $VERSION = '0.788'; | ||
| 9 | |||
| 10 | foreach my $type (__PACKAGE__->available_method_types) | ||
| 11 | { | ||
| 12 | __PACKAGE__->method_maker_type($type => 'timestamp_with_time_zone'); | ||
| 13 | } | ||
| 14 | |||
| 15 | sub type { 'timestamp with time zone' } | ||
| 16 | |||
| 17 | sub should_inline_value | ||
| 18 | { | ||
| 19 | my($self, $db, $value) = @_; | ||
| 20 | no warnings 'uninitialized'; | ||
| 21 | return (($db->validate_timestamp_keyword($value) && $db->should_inline_timestamp_keyword($value)) || | ||
| 22 | ($db->keyword_function_calls && $value =~ /^\w+\(.*\)$/)) ? 1 : 0; | ||
| 23 | } | ||
| 24 | |||
| 25 | sub parse_value | ||
| 26 | { | ||
| 27 | my($self, $db) = (shift, shift); | ||
| 28 | |||
| 29 | $self->parse_error(undef); | ||
| 30 | |||
| 31 | my $dt = $db->parse_timestamp_with_time_zone(@_); | ||
| 32 | |||
| 33 | unless($dt) | ||
| 34 | { | ||
| 35 | $dt = Rose::DateTime::Util::parse_date($_[0], $self->time_zone || $db->server_time_zone); | ||
| 36 | |||
| 37 | if(my $error = Rose::DateTime::Util->error) | ||
| 38 | { | ||
| 39 | $self->parse_error("Could not parse value '$_[0]' for column $self: $error") | ||
| 40 | if(defined $_[0]); | ||
| 41 | } | ||
| 42 | } | ||
| 43 | |||
| 44 | return $dt; | ||
| 45 | } | ||
| 46 | |||
| 47 | sub format_value { shift; shift->format_timestamp_with_time_zone(@_) } | ||
| 48 | |||
| 49 | 1; | ||
| 50 | |||
| 51 | __END__ |