summaryrefslogtreecommitdiff
path: root/lib/Travelynx.pm
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2021-09-03 20:24:54 +0200
committerDaniel Friesel <derf@finalrewind.org>2021-09-03 20:24:54 +0200
commit9d4f3f8ce124023f704d5ca1a9e7a87029b43073 (patch)
tree512825f4a172320944d760a833b4e3c98d00d7c0 /lib/Travelynx.pm
parent564f2fb354e2681ef8d7d4fe3c95049b35aff462 (diff)
Ensure that database timezone matches IRIS time zone1.21.1
All travelynx and IRIS timestamps are Europe/Berlin. And the DateTime objects know that they are Europe/Berlin. However, when inserting into a timestamp with time zone column, Mojo::Pg or one of the backend DBI/DBD libraries does not respect the time zone. So, UTC+1 or UTC+2 timestamps are treated as UTC+0, resulting in major mayhem.
Diffstat (limited to 'lib/Travelynx.pm')
-rwxr-xr-xlib/Travelynx.pm9
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/Travelynx.pm b/lib/Travelynx.pm
index 2618191..8ef5fbf 100755
--- a/lib/Travelynx.pm
+++ b/lib/Travelynx.pm
@@ -369,6 +369,15 @@ sub startup {
state $pg
= Mojo::Pg->new("postgresql://${user}\@${host}:${port}/${dbname}")
->password($pw);
+
+ $pg->on(
+ connection => sub {
+ my ( $pg, $dbh ) = @_;
+ $dbh->do("set time zone 'Europe/Berlin'");
+ }
+ );
+
+ return $pg;
}
);