Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 4afdef6

Browse files
committedMar 22, 2017
Allow dates beyond 2038
1 parent 2303280 commit 4afdef6

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed
 

‎include/my_time.h

+7-5
Original file line numberDiff line numberDiff line change
@@ -31,23 +31,25 @@ extern const char my_zero_datetime6[]; /* "0000-00-00 00:00:00.000000" */
3131

3232
/*
3333
Portable time_t replacement.
34-
Should be signed and hold seconds for 1902 -- 2038-01-19 range
35-
i.e at least a 32bit variable
34+
Should be signed and hold seconds for 1902 -- 9999 range
35+
i.e at least a 64bit variable
3636
3737
Using the system built in time_t is not an option as
3838
we rely on the above requirements in the time functions
3939
*/
40-
typedef long my_time_t;
40+
typedef long long my_time_t;
4141

4242
typedef enum enum_mysql_timestamp_type timestamp_type;
4343

4444
#define MY_TIME_T_MAX LONG_MAX
4545
#define MY_TIME_T_MIN LONG_MIN
4646

4747
/* Time handling defaults */
48-
#define TIMESTAMP_MAX_YEAR 2038
48+
#define TIMESTAMP_MAX_YEAR 9999
4949
#define TIMESTAMP_MIN_YEAR (1900 + YY_PART_YEAR - 1)
50-
#define TIMESTAMP_MAX_VALUE INT_MAX32
50+
51+
/* 253202544000 = (9999 - 1970) * 365 * 24 * 60 * 60 */
52+
#define TIMESTAMP_MAX_VALUE 253202544000
5153
#define TIMESTAMP_MIN_VALUE 1
5254

5355
/* two-digit years < this are 20..; >= this are 19.. */

‎sql/tztime.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -2422,7 +2422,7 @@ print_tz_as_sql(const char* tz_name, const TIME_ZONE_INFO *sp)
24222422
printf("INSERT INTO time_zone_transition \
24232423
(Time_zone_id, Transition_time, Transition_type_id) VALUES\n");
24242424
for (i= 0; i < sp->timecnt; i++)
2425-
printf("%s(@time_zone_id, %ld, %u)\n", (i == 0 ? " " : ","), sp->ats[i],
2425+
printf("%s(@time_zone_id, %lld, %u)\n", (i == 0 ? " " : ","), sp->ats[i],
24262426
(uint)sp->types[i]);
24272427
printf(";\n");
24282428
}
@@ -2467,7 +2467,7 @@ print_tz_leaps_as_sql(const TIME_ZONE_INFO *sp)
24672467
printf("INSERT INTO time_zone_leap_second \
24682468
(Transition_time, Correction) VALUES\n");
24692469
for (i= 0; i < sp->leapcnt; i++)
2470-
printf("%s(%ld, %ld)\n", (i == 0 ? " " : ","),
2470+
printf("%s(%lld, %ld)\n", (i == 0 ? " " : ","),
24712471
sp->lsis[i].ls_trans, sp->lsis[i].ls_corr);
24722472
printf(";\n");
24732473
}

0 commit comments

Comments
 (0)
Failed to load comments.