Skip to content

Allow dates beyond 2038 #130

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions include/my_time.h
Original file line number Diff line number Diff line change
@@ -31,23 +31,25 @@ extern const char my_zero_datetime6[]; /* "0000-00-00 00:00:00.000000" */

/*
Portable time_t replacement.
Should be signed and hold seconds for 1902 -- 2038-01-19 range
i.e at least a 32bit variable
Should be signed and hold seconds for 1902 -- 9999 range
i.e at least a 64bit variable

Using the system built in time_t is not an option as
we rely on the above requirements in the time functions
*/
typedef long my_time_t;
typedef long long my_time_t;

typedef enum enum_mysql_timestamp_type timestamp_type;

#define MY_TIME_T_MAX LONG_MAX
#define MY_TIME_T_MIN LONG_MIN

/* Time handling defaults */
#define TIMESTAMP_MAX_YEAR 2038
#define TIMESTAMP_MAX_YEAR 9999
#define TIMESTAMP_MIN_YEAR (1900 + YY_PART_YEAR - 1)
#define TIMESTAMP_MAX_VALUE INT_MAX32

/* 253370764800 = 9999-01-01 */
#define TIMESTAMP_MAX_VALUE 253370764800
#define TIMESTAMP_MIN_VALUE 1

/* two-digit years < this are 20..; >= this are 19.. */
4 changes: 2 additions & 2 deletions sql/tztime.cc
Original file line number Diff line number Diff line change
@@ -2422,7 +2422,7 @@ print_tz_as_sql(const char* tz_name, const TIME_ZONE_INFO *sp)
printf("INSERT INTO time_zone_transition \
(Time_zone_id, Transition_time, Transition_type_id) VALUES\n");
for (i= 0; i < sp->timecnt; i++)
printf("%s(@time_zone_id, %ld, %u)\n", (i == 0 ? " " : ","), sp->ats[i],
printf("%s(@time_zone_id, %lld, %u)\n", (i == 0 ? " " : ","), sp->ats[i],
(uint)sp->types[i]);
printf(";\n");
}
@@ -2467,7 +2467,7 @@ print_tz_leaps_as_sql(const TIME_ZONE_INFO *sp)
printf("INSERT INTO time_zone_leap_second \
(Transition_time, Correction) VALUES\n");
for (i= 0; i < sp->leapcnt; i++)
printf("%s(%ld, %ld)\n", (i == 0 ? " " : ","),
printf("%s(%lld, %ld)\n", (i == 0 ? " " : ","),
sp->lsis[i].ls_trans, sp->lsis[i].ls_corr);
printf(";\n");
}