fb 0.6.2 → 0.6.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/fb.c +30 -6
  2. data/test/DataTypesTestCases.rb +1 -1
  3. metadata +1 -1
data/fb.c CHANGED
@@ -199,10 +199,10 @@ static VALUE fb_error_msg(ISC_STATUS *isc_status)
199
199
  #endif
200
200
 
201
201
  struct time_object {
202
- struct timeval tv;
203
- struct tm tm;
204
- int gmt;
205
- int tm_got;
202
+ struct timeval tv;
203
+ struct tm tm;
204
+ int gmt;
205
+ int tm_got;
206
206
  };
207
207
 
208
208
  #define GetTimeval(obj, tobj) \
@@ -210,9 +210,33 @@ struct time_object {
210
210
 
211
211
  static VALUE fb_mktime(struct tm *tm, char *which)
212
212
  {
213
+ #if defined(_WIN32)
214
+ if (tm->tm_year + 1900 < 1970)
215
+ {
216
+ tm->tm_year = 70;
217
+ tm->tm_mon = 0;
218
+ tm->tm_mday = 1;
219
+ tm->tm_hour = 0;
220
+ tm->tm_min = 0;
221
+ tm->tm_sec = 0;
222
+ }
223
+ #endif
224
+ #if defined(_LP64) || defined(__LP64__) || defined(__arch64__)
225
+ // No need to floor time on 64-bit Unix.
226
+ #else
227
+ if (tm->tm_year + 1900 < 1902)
228
+ {
229
+ tm->tm_year = 2;
230
+ tm->tm_mon = 0;
231
+ tm->tm_mday = 1;
232
+ tm->tm_hour = 0;
233
+ tm->tm_min = 0;
234
+ tm->tm_sec = 0;
235
+ }
236
+ #endif
213
237
  return rb_funcall(
214
238
  rb_cTime, rb_intern(which), 6,
215
- INT2FIX(tm->tm_year), INT2FIX(tm->tm_mon + 1), INT2FIX(tm->tm_mday),
239
+ INT2FIX(tm->tm_year + 1900), INT2FIX(tm->tm_mon + 1), INT2FIX(tm->tm_mday),
216
240
  INT2FIX(tm->tm_hour), INT2FIX(tm->tm_min), INT2FIX(tm->tm_sec));
217
241
  }
218
242
 
@@ -1982,7 +2006,7 @@ static VALUE fb_cursor_fetch(struct FbCursor *fb_cursor)
1982
2006
 
1983
2007
  case SQL_TYPE_TIME:
1984
2008
  isc_decode_sql_time((ISC_TIME *)var->sqldata, &tms);
1985
- tms.tm_year = 2000;
2009
+ tms.tm_year = 100;
1986
2010
  tms.tm_mon = 0;
1987
2011
  tms.tm_mday = 1;
1988
2012
  val = fb_mktime(&tms, "utc");
@@ -153,7 +153,7 @@ class DataTypesTestCases < Test::Unit::TestCase
153
153
  assert_equal gen_vc10(i), row["VC10"], "VARCHAR(10)"
154
154
  assert_equal gen_vc10000(i), row["VC10000"], "VARCHAR(10000)"
155
155
  assert_equal gen_dt(i), row["DT"], "DATE"
156
- #assert_equal gen_tm(i).strftime("%H%M%S"), row["TM"].utc.strftime("%H%M%S"), "TIME"
156
+ assert_equal gen_tm(i).strftime("%H%M%S"), row["TM"].utc.strftime("%H%M%S"), "TIME"
157
157
  assert_equal gen_ts(i), row["TS"], "TIMESTAMP"
158
158
  assert_equal gen_n92(i), row["N92"], "NUMERIC"
159
159
  assert_equal gen_d92(i), row["D92"], "DECIMAL"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.2
4
+ version: 0.6.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brent Rowland