<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -3,6 +3,7 @@
 #include &lt;string.h&gt;
 #include &lt;math.h&gt;
 #include &lt;time.h&gt;
+#include &lt;locale.h&gt;
 #include &lt;libpq-fe.h&gt;
 #include &quot;type-oids.h&quot;
 
@@ -121,6 +122,9 @@ static VALUE parse_date_time(const char *date) {
 	int jd;
 	do_int64 num, den;
 	
+    long int gmt_offset;
+    int is_dst;
+	
 	time_t rawtime;
 	struct tm * timeinfo;
 
@@ -145,21 +149,25 @@ static VALUE parse_date_time(const char *date) {
 	} else if (tokens_read == 3) {
     return parse_date(date);
 	} else if (tokens_read &gt;= (max_tokens - 3)) {
-		// We read the Date and Time, maybe the Sign, default to the current locale's offset
+		// We read the Date and Time, default to the current locale's offset
 		
 		// Get localtime
 		time(&amp;rawtime);
-		timeinfo = localtime(&amp;rawtime);
-		
-		int offset = -timezone;
-		int is_dst = timeinfo-&gt;tm_isdst * 3600;
+        timeinfo = localtime(&amp;rawtime);
 		
-		offset += is_dst;
-			
-		// TODO: Refactor the following few lines to do the calculation with the *seconds*
-		// value instead of having to do the hour/minute math
-		hour_offset = offset / 3600;
-		minute_offset = offset % 3600 / 60;
+		is_dst = timeinfo-&gt;tm_isdst * 3600;
+        
+        // Reset to GM Time
+        timeinfo = gmtime(&amp;rawtime);
+        
+        gmt_offset = mktime(timeinfo) - rawtime;
+        
+        if ( is_dst &gt; 0 )
+            gmt_offset -= is_dst;
+        
+        hour_offset = -(gmt_offset / 3600);
+        minute_offset = -(gmt_offset % 3600 / 60);
+        
 	} else {
 		// Something went terribly wrong
 		rb_raise(ePostgresError, &quot;Couldn't parse date: %s&quot;, date);</diff>
      <filename>do_postgres/ext/do_postgres_ext.c</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>d46ac0ba667af3a6d3298446fa26e22f58e4dfc1</id>
    </parent>
  </parents>
  <author>
    <name>Bernerd Schaefer</name>
    <email>bj.schaefer@gmail.com</email>
  </author>
  <url>http://github.com/sam/do/commit/ac6c48f690e957eb5526b955a1e500b3079729a3</url>
  <id>ac6c48f690e957eb5526b955a1e500b3079729a3</id>
  <committed-date>2008-06-09T09:58:30-07:00</committed-date>
  <authored-date>2008-06-09T09:58:30-07:00</authored-date>
  <message>do_postgres timezones are now fully functional</message>
  <tree>dc0d85bbc48907019d422e5780fd3fce240b6e0a</tree>
  <committer>
    <name>Bernerd Schaefer</name>
    <email>bj.schaefer@gmail.com</email>
  </committer>
</commit>
