diff options
author | Struan Donald <struan@exo.org.uk> | 2011-05-27 16:40:36 +0100 |
---|---|---|
committer | Struan Donald <struan@exo.org.uk> | 2011-05-27 16:43:42 +0100 |
commit | a888f0e31747bd6e1b3733d70569d151607fde22 (patch) | |
tree | a88999ecf1d715706143ad27cd75810c12c374e7 /perllib/FixMyStreet/DB/Result/Comment.pm | |
parent | 778f6498b17f51aa30a948ede177f0c681c0f228 (diff) |
check for uninflated/null dates before trying to set the timezoned
Diffstat (limited to 'perllib/FixMyStreet/DB/Result/Comment.pm')
-rw-r--r-- | perllib/FixMyStreet/DB/Result/Comment.pm | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/perllib/FixMyStreet/DB/Result/Comment.pm b/perllib/FixMyStreet/DB/Result/Comment.pm index f51c939ff..40801306b 100644 --- a/perllib/FixMyStreet/DB/Result/Comment.pm +++ b/perllib/FixMyStreet/DB/Result/Comment.pm @@ -80,7 +80,11 @@ with 'FixMyStreet::Roles::Abuser'; my $tz = DateTime::TimeZone->new( name => "local" ); sub created_local { - return shift->created->set_time_zone($tz); + my $self = shift; + + return $self->created + ? $self->created->set_time_zone($tz) + : $self->created; } sub confirmed_local { @@ -88,9 +92,9 @@ sub confirmed_local { # if confirmed is null then it doesn't get inflated so don't # try and set the timezone - return $self->confirmed->set_time_zone($tz) if $self->confirmed; - - return 0; + return $self->confirmed + ? $self->confirmed->set_time_zone($tz) + : $self->confirmed; } # You can replace this text with custom code or comments, and it will be preserved on regeneration |