diff options
Diffstat (limited to 'perllib/FixMyStreet/DB/Result/Alert.pm')
-rw-r--r-- | perllib/FixMyStreet/DB/Result/Alert.pm | 31 |
1 files changed, 15 insertions, 16 deletions
diff --git a/perllib/FixMyStreet/DB/Result/Alert.pm b/perllib/FixMyStreet/DB/Result/Alert.pm index ca9ad45c2..fc84c8fd5 100644 --- a/perllib/FixMyStreet/DB/Result/Alert.pm +++ b/perllib/FixMyStreet/DB/Result/Alert.pm @@ -77,22 +77,21 @@ with 'FixMyStreet::Roles::Abuser'; my $tz = DateTime::TimeZone->new( name => "local" ); - -sub whensubscribed_local { - my $self = shift; - - return $self->whensubscribed - ? $self->whensubscribed->set_time_zone($tz) - : $self->whensubscribed; -} - -sub whendisabled_local { - my $self = shift; - - return $self->whendisabled - ? $self->whendisabled->set_time_zone($tz) - : $self->whendisabled; -} +my $tz_f; +$tz_f = DateTime::TimeZone->new( name => FixMyStreet->config('TIME_ZONE') ) + if FixMyStreet->config('TIME_ZONE'); + +my $stz = sub { + my ( $orig, $self ) = ( shift, shift ); + my $s = $self->$orig(@_); + return $s unless $s && UNIVERSAL::isa($s, "DateTime"); + $s->set_time_zone($tz); + $s->set_time_zone($tz_f) if $tz_f; + return $s; +}; + +around whensubscribed => $stz; +around whendisabled => $stz; =head2 confirm |