|
4 | 4 | static rb_encoding *binaryEncoding;
|
5 | 5 | #endif
|
6 | 6 |
|
7 |
| -#define MYSQL2_MAX_YEAR 2038 |
| 7 | +#if SIZEOF_INT < SIZEOF_LONG |
| 8 | +/** |
| 9 | + * on 64bit platforms we can handle dates way outside 2038-01-19T03:14:07 |
| 10 | + * because of how I'm performing the math below, this will allow a maximum |
| 11 | + * timestamp of 9846-12-12T11:5999:59 |
| 12 | +*/ |
| 13 | +#define MYSQL2_MAX_YEAR 9999 |
| 14 | +#else |
| 15 | +/** |
| 16 | + * on 32bit platforms the maximum date the Time class can handle is 2038-01-19T03:14:07 |
| 17 | + * 2082 = 2038+1+19+3+14+7 |
| 18 | + */ |
| 19 | +#define MYSQL2_MAX_YEAR 2082 |
| 20 | +#endif |
8 | 21 |
|
9 | 22 | #ifdef NEGATIVE_TIME_T
|
10 |
| - /* 1901-12-13 20:45:52 UTC : The oldest time in 32-bit signed time_t. */ |
| 23 | +/* 1901-12-13 20:45:52 UTC : The oldest time in 32-bit signed time_t. */ |
11 | 24 | #define MYSQL2_MIN_YEAR 1902
|
12 | 25 | #else
|
13 |
| - /* 1970-01-01 00:00:00 UTC : The Unix epoch - the oldest time in portable time_t. */ |
| 26 | +/* 1970-01-01 00:00:00 UTC : The Unix epoch - the oldest time in portable time_t. */ |
14 | 27 | #define MYSQL2_MIN_YEAR 1970
|
15 | 28 | #endif
|
16 | 29 |
|
@@ -240,7 +253,7 @@ static VALUE rb_mysql_result_fetch_row(VALUE self, ID db_timezone, ID app_timezo
|
240 | 253 | rb_raise(cMysql2Error, "Invalid date: %s", row[i]);
|
241 | 254 | val = Qnil;
|
242 | 255 | } else {
|
243 |
| - if (year < MYSQL2_MIN_YEAR || year+month+day > MYSQL2_MAX_YEAR) { // use DateTime instead |
| 256 | + if (year < MYSQL2_MIN_YEAR || year+month+day+hour+min+sec > MYSQL2_MAX_YEAR) { // use DateTime instead |
244 | 257 | VALUE offset = INT2NUM(0);
|
245 | 258 | if (db_timezone == intern_local) {
|
246 | 259 | offset = rb_funcall(cMysql2Client, intern_local_offset, 0);
|
|
0 commit comments