From d9a609771f7bf6ef26a4f38c87a6e0720a821b89 Mon Sep 17 00:00:00 2001 From: ochran <49185817+ochran@users.noreply.github.com> Date: Sun, 7 Apr 2019 11:41:50 +0100 Subject: [PATCH 1/2] Use TIME_ZONE ENV var if supplied --- src/mysql.cr | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/mysql.cr b/src/mysql.cr index ceaff6b..41de6d9 100644 --- a/src/mysql.cr +++ b/src/mysql.cr @@ -12,6 +12,10 @@ module MySql alias Any = DB::Any | Int16 | Int8 | Time::Span + def self.time_zone + ENV.has_key?("DB_TIME_ZONE") ? Time::Location.load(ENV["DB_TIME_ZONE"]) : Time::Location::UTC + end + # :nodoc: - TIME_ZONE = Time::Location::UTC + TIME_ZONE = MySql.time_zone end From 00926ba9d4d8315db1cee7740a1c1085e863ba1b Mon Sep 17 00:00:00 2001 From: ochran <49185817+ochran@users.noreply.github.com> Date: Sun, 7 Apr 2019 12:13:56 +0100 Subject: [PATCH 2/2] README update to reflect timezone change --- README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 008b50f..1a09e0c 100644 --- a/README.md +++ b/README.md @@ -57,4 +57,7 @@ DB.open "mysql://root@localhost/test" do |db| end end end -``` \ No newline at end of file +``` +#### Time Zone +To change the time zone that this library uses (defaults to UTC), set a DB_TIME_ZONE env var to the desired location. +Example: `DB_TIME_ZONE="Europe/Berlin"`