Title: [709] trunk/activerecord-jdbc: - Backport portion of date/timestamp handling so that it's compatible w/ JRuby 1.0
- Revision
- 709
- Author
- nicksieger
- Date
- 2007-08-24 03:41:56 -0400 (Fri, 24 Aug 2007)
Log Message
- Backport portion of date/timestamp handling so that it's compatible w/ JRuby 1.0
- Allow specifying JRuby version to run maven-based tests with -Djruby.version=...
Modified Paths
Diff
Modified: trunk/activerecord-jdbc/pom.xml (708 => 709)
--- trunk/activerecord-jdbc/pom.xml 2007-08-24 07:07:34 UTC (rev 708)
+++ trunk/activerecord-jdbc/pom.xml 2007-08-24 07:41:56 UTC (rev 709)
@@ -18,7 +18,7 @@
<dependency>
<groupId>org.jruby</groupId>
<artifactId>jruby</artifactId>
- <version>1.0.1</version>
+ <version>${jruby.version}</version>
</dependency>
</dependencies>
@@ -103,6 +103,7 @@
</activation>
<properties>
<test.task>test</test.task>
+ <jruby.version>1.0.1</jruby.version>
</properties>
</profile>
</profiles>
Modified: trunk/activerecord-jdbc/src/java/JdbcAdapterInternalService.java (708 => 709)
--- trunk/activerecord-jdbc/src/java/JdbcAdapterInternalService.java 2007-08-24 07:07:34 UTC (rev 708)
+++ trunk/activerecord-jdbc/src/java/JdbcAdapterInternalService.java 2007-08-24 07:41:56 UTC (rev 709)
@@ -703,9 +703,15 @@
ps.setString(index, RubyString.objAsString(value).toString());
}
} else {
- java.sql.Timestamp ts = new java.sql.Timestamp(((RubyTime)value).getJavaDate().getTime());
- ts.setNanos((int)(((RubyTime)value).getUSec()*1000));
- ps.setTimestamp(index, ts, ((RubyTime)value).getJavaCalendar());
+ RubyTime rubyTime = (RubyTime) value;
+ java.util.Date date = rubyTime.getJavaDate();
+ long millis = date.getTime();
+ long micros = rubyTime.microseconds() - millis / 1000;
+ java.sql.Timestamp ts = new java.sql.Timestamp(millis);
+ java.util.Calendar cal = Calendar.getInstance();
+ cal.setTime(date);
+ ts.setNanos((int)(micros * 1000));
+ ps.setTimestamp(index, ts, cal);
}
break;
case Types.BOOLEAN:
_______________________________________________
Jruby-extras-devel mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/jruby-extras-devel