From ee8db41223529ba1a6975fabbbacafdd791cbcb4 Mon Sep 17 00:00:00 2001
From: Martin Samson <pyrolian@gmail.com>
Date: Tue, 26 Jul 2011 23:37:33 -0400
Subject: [PATCH] Fixes timezone when you are not in the east emisphere. Not
 everybody using MonetDB lives in the netherlands :)

---
 .../connection_adapters/monetdb_adapter.rb            |  9 +++------
 lib/MonetDBConnection.rb                              | 11 +++--------
 2 files changed, 6 insertions(+), 14 deletions(-)

diff --git a/adapter/lib/active_record/connection_adapters/monetdb_adapter.rb b/adapter/lib/active_record/connection_adapters/monetdb_adapter.rb
index de041a2..bfea38f 100644
--- a/adapter/lib/active_record/connection_adapters/monetdb_adapter.rb
+++ b/adapter/lib/active_record/connection_adapters/monetdb_adapter.rb
@@ -29,17 +29,14 @@ require 'MonetDB'
 module ActiveRecord
   class Base
     # Establishes a connection to the database that's used by all Active Record objects
-    def self.monetdb_connection(config) 
-      #TODO: is this required?
-      #require_library_or_gem('MonetDB')
-
+    def self.monetdb_connection(config)
       # extract connection parameters
       config 	= config.symbolize_keys
 
       host = config[:host] || "127.0.0.1"
       port = config[:port] || 50000
-      username 	= config[:username].to_s if config[:username] || "monetdb"
-      password	= config[:password].to_s if config[:password] || "monetdb"
+      username 	= config[:username].to_s if config[:username]
+      password	= config[:password].to_s if config[:password]
 
       # Use "sql" as default language if none is specified
       lang = config[:lang] || "sql"
diff --git a/lib/MonetDBConnection.rb b/lib/MonetDBConnection.rb
index 1e3f8a0..c08f70e 100644
--- a/lib/MonetDBConnection.rb
+++ b/lib/MonetDBConnection.rb
@@ -442,15 +442,10 @@ class MonetDBConnection
   # Sets the time zone according to the Operating System settings
   def set_timezone()
     tz = Time.new
-    tz_offset = tz.gmt_offset / @@HOUR
-      
-    if tz_offset <= 9 # verify minute count!
-      tz_offset = "'+0" + tz_offset.to_s + ":00'"
-    else
-      tz_offset = "'+" + tz_offset.to_s + ":00'"
-    end
+    tz_offset = "'%+03d:00'" % (tz.gmt_offset / @@HOUR)
+
     query_tz = "sSET TIME ZONE INTERVAL " + tz_offset + " HOUR TO MINUTE;"
-    
+
     # Perform the query directly within the method
     send(query_tz)
     response = receive
-- 
GitLab