aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/DBIx/Class/FixMyStreet/InflateColumn/DateTime.pm
diff options
context:
space:
mode:
authorMatthew Somerville <matthew-github@dracos.co.uk>2019-05-03 10:47:33 +0100
committerMatthew Somerville <matthew-github@dracos.co.uk>2019-05-03 10:47:33 +0100
commit654fb3942a04e53c09d7cf516c7bf6a3523d5557 (patch)
tree7149163310cd3da46c01ed67eb6e969307abb452 /perllib/DBIx/Class/FixMyStreet/InflateColumn/DateTime.pm
parent26d2bb9dddb0f9e10267ec47dbcb4a1571021a8b (diff)
parent5c06c6c6894a9094a8c60324ac000214964f5da8 (diff)
Merge branch 'moderation-dst-time'
Diffstat (limited to 'perllib/DBIx/Class/FixMyStreet/InflateColumn/DateTime.pm')
-rw-r--r--perllib/DBIx/Class/FixMyStreet/InflateColumn/DateTime.pm36
1 files changed, 36 insertions, 0 deletions
diff --git a/perllib/DBIx/Class/FixMyStreet/InflateColumn/DateTime.pm b/perllib/DBIx/Class/FixMyStreet/InflateColumn/DateTime.pm
new file mode 100644
index 000000000..f2089d5a3
--- /dev/null
+++ b/perllib/DBIx/Class/FixMyStreet/InflateColumn/DateTime.pm
@@ -0,0 +1,36 @@
+package DBIx::Class::FixMyStreet::InflateColumn::DateTime;
+
+use strict;
+use warnings;
+use base qw/DBIx::Class::InflateColumn::DateTime/;
+use FixMyStreet;
+use namespace::clean;
+
+sub _post_inflate_datetime {
+ my $self = shift;
+ my $dt = $self->next::method(@_);
+ FixMyStreet->set_time_zone($dt);
+ return $dt;
+}
+
+sub _pre_deflate_datetime {
+ my $self = shift;
+ my $dt = $self->next::method(@_);
+ $dt->set_time_zone(FixMyStreet->local_time_zone);
+ return $dt;
+}
+
+1;
+
+__END__
+
+=head1 NAME
+
+DBIx::Class::FixMyStreet::InflateColumn::DateTime
+
+=head1 DESCRIPTION
+
+This acts the same as DBIx::Class::InflateColumn::DateTime, as if a
+'local' timezone object was attached to every datetime column, plus
+alters the timezone upon inflation to the configured timezone if it
+has been set, and uses a singleton to prevent needless disc access.