summaryrefslogtreecommitdiff
path: root/sql-common/my_time.c
diff options
context:
space:
mode:
authormonty@mysql.com/narttu.mysql.fi <>2007-03-23 22:08:31 +0200
committermonty@mysql.com/narttu.mysql.fi <>2007-03-23 22:08:31 +0200
commit193360364703b5aeba78925aa5cdbf1f28a392c8 (patch)
treee49fe06028525f2e9ade2717aa57f2ed8c319576 /sql-common/my_time.c
parent5e0596f4e1e8a30139b3bab62095a2d301d7970c (diff)
downloadmariadb-git-193360364703b5aeba78925aa5cdbf1f28a392c8.tar.gz
Removed not used define YY_MAGIC_BELOW
Made year 2000 handling more uniform Removed year 2000 handling out from calc_days() The above removes some bugs in date/datetimes with year between 0 and 200 Now we get a note when we insert a datetime value into a date column For default values to CREATE, don't give errors for warning level NOTE Fixed some compiler failures Added library ws2_32 for windows compilation (needed if we want to compile with IOCP support) Removed duplicate typedef TIME and replaced it with MYSQL_TIME Better (more complete) fix for: Bug#21103 "DATE column not compared as DATE" Fixed properly Bug#18997 "DATE_ADD and DATE_SUB perform year2K autoconversion magic on 4-digit year value" Fixed Bug#23093 "Implicit conversion of 9912101 to date does not match cast(9912101 as date)"
Diffstat (limited to 'sql-common/my_time.c')
-rw-r--r--sql-common/my_time.c39
1 files changed, 33 insertions, 6 deletions
diff --git a/sql-common/my_time.c b/sql-common/my_time.c
index e62003d13ed..4aad97f8249 100644
--- a/sql-common/my_time.c
+++ b/sql-common/my_time.c
@@ -730,7 +730,39 @@ void init_time(void)
}
- /* Calculate nr of day since year 0 in new date-system (from 1615) */
+/*
+ Handle 2 digit year conversions
+
+ SYNOPSIS
+ year_2000_handling()
+ year 2 digit year
+
+ RETURN
+ Year between 1970-2069
+*/
+
+uint year_2000_handling(uint year)
+{
+ if ((year=year+1900) < 1900+YY_PART_YEAR)
+ year+=100;
+ return year;
+}
+
+
+/*
+ Calculate nr of day since year 0 in new date-system (from 1615)
+
+ SYNOPSIS
+ calc_daynr()
+ year Year (exact 4 digit year, no year conversions)
+ month Month
+ day Day
+
+ NOTES: 0000-00-00 is a valid date, and will return 0
+
+ RETURN
+ Days since 0000-00-00
+*/
long calc_daynr(uint year,uint month,uint day)
{
@@ -740,11 +772,6 @@ long calc_daynr(uint year,uint month,uint day)
if (year == 0 && month == 0 && day == 0)
DBUG_RETURN(0); /* Skip errors */
- if (year < YY_MAGIC_BELOW)
- {
- if ((year=year+1900) < 1900+YY_PART_YEAR)
- year+=100;
- }
delsum= (long) (365L * year+ 31*(month-1) +day);
if (month <= 2)
year--;