diff options
author | unknown <jani@ua141d10.elisa.omakaista.fi> | 2007-04-10 16:28:47 +0300 |
---|---|---|
committer | unknown <jani@ua141d10.elisa.omakaista.fi> | 2007-04-10 16:28:47 +0300 |
commit | a2989a35f51ce3481317759f23da4e663c37ac15 (patch) | |
tree | cae620a49c973ba2cfe8c707254295e28815efcc /sql-common | |
parent | 37feda2596128fec33ac0e4fe8ff0cd35efd1dec (diff) | |
parent | 64e13b05e794e50777442a4c163e41793685833f (diff) | |
download | mariadb-git-a2989a35f51ce3481317759f23da4e663c37ac15.tar.gz |
Merge jamppa@bk-internal.mysql.com:/home/bk/mysql-5.1
into ua141d10.elisa.omakaista.fi:/home/my/bk/mysql-5.1-marvel
client/mysqlcheck.c:
Auto merged
client/mysqldump.c:
Auto merged
include/my_time.h:
Auto merged
mysql-test/r/date_formats.result:
Auto merged
mysql-test/r/grant.result:
Auto merged
mysql-test/r/sp.result:
Auto merged
mysql-test/r/type_date.result:
Auto merged
mysql-test/r/type_datetime.result:
Auto merged
mysql-test/t/grant.test:
Auto merged
mysql-test/t/sp.test:
Auto merged
mysys/my_malloc.c:
Auto merged
mysys/my_static.c:
Auto merged
mysys/safemalloc.c:
Auto merged
sql/event_queue.cc:
Auto merged
sql/field.cc:
Auto merged
sql/field.h:
Auto merged
sql/ha_ndbcluster.cc:
Auto merged
sql/handler.cc:
Auto merged
sql/item.h:
Auto merged
sql/item_cmpfunc.cc:
Auto merged
sql/item_func.h:
Auto merged
sql/log.cc:
Auto merged
sql/log_event.cc:
Auto merged
sql/mysql_priv.h:
Auto merged
sql/set_var.cc:
Auto merged
sql/slave.cc:
Auto merged
sql/sp.cc:
Auto merged
sql/sp_head.cc:
Auto merged
sql/sql_base.cc:
Auto merged
sql/sql_class.cc:
Auto merged
sql/sql_db.cc:
Auto merged
sql/sql_delete.cc:
Auto merged
sql/sql_insert.cc:
Auto merged
sql/sql_repl.cc:
Auto merged
sql/sql_select.cc:
Auto merged
sql/sql_show.cc:
Auto merged
sql/sql_table.cc:
Auto merged
sql/sql_update.cc:
Auto merged
sql/table.cc:
Auto merged
sql-common/client.c:
Auto merged
sql-common/my_time.c:
Auto merged
sql/time.cc:
Auto merged
storage/archive/ha_archive.cc:
Auto merged
storage/innobase/handler/ha_innodb.cc:
Auto merged
storage/ndb/src/mgmclient/CommandInterpreter.cpp:
Auto merged
tests/mysql_client_test.c:
Auto merged
client/client_priv.h:
Manual merge with main 5.1 source.
sql/event_data_objects.cc:
Manual merge with main 5.1 source.
sql/event_db_repository.cc:
Manual merge with main 5.1 source.
sql/mysqld.cc:
Manual merge with main 5.1 source.
sql/sql_load.cc:
Manual merge with main 5.1 source.
sql/sql_parse.cc:
Manual merge with main 5.1 source.
Diffstat (limited to 'sql-common')
-rw-r--r-- | sql-common/my_time.c | 62 |
1 files changed, 45 insertions, 17 deletions
diff --git a/sql-common/my_time.c b/sql-common/my_time.c index 0530482237e..f08e2e00ef3 100644 --- a/sql-common/my_time.c +++ b/sql-common/my_time.c @@ -453,7 +453,7 @@ err: /* - Convert a time string to a TIME struct. + Convert a time string to a MYSQL_TIME struct. SYNOPSIS str_to_time() @@ -639,11 +639,11 @@ fractional: l_time->second_part= date[4]; l_time->time_type= MYSQL_TIMESTAMP_TIME; - /* Check if the value is valid and fits into TIME range */ + /* Check if the value is valid and fits into MYSQL_TIME range */ if (check_time_range(l_time, warning)) return 1; - /* Check if there is garbage at end of the TIME specification */ + /* Check if there is garbage at end of the MYSQL_TIME specification */ if (str != end) { do @@ -660,11 +660,11 @@ fractional: /* - Check 'time' value to lie in the TIME range + Check 'time' value to lie in the MYSQL_TIME range SYNOPSIS: check_time_range() - time pointer to TIME value + time pointer to MYSQL_TIME value warning set MYSQL_TIME_WARN_OUT_OF_RANGE flag if the value is out of range DESCRIPTION @@ -727,7 +727,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) { @@ -737,11 +769,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--; @@ -978,7 +1005,7 @@ void set_zero_time(MYSQL_TIME *tm, enum enum_mysql_timestamp_type time_type) /* Functions to convert time/date/datetime value to a string, using default format. - This functions don't check that given TIME structure members are + This functions don't check that given MYSQL_TIME structure members are in valid range. If they are not, return value won't reflect any valid date either. Additionally, make_time doesn't take into account time->day member: it's assumed that days have been converted @@ -1064,7 +1091,7 @@ int my_TIME_to_str(const MYSQL_TIME *l_time, char *to) DESCRIPTION Convert a datetime value of formats YYMMDD, YYYYMMDD, YYMMDDHHMSS, - YYYYMMDDHHMMSS to broken-down TIME representation. Return value in + YYYYMMDDHHMMSS to broken-down MYSQL_TIME representation. Return value in YYYYMMDDHHMMSS format as side-effect. This function also checks if datetime value fits in DATETIME range. @@ -1120,6 +1147,7 @@ longlong number_to_datetime(longlong nr, MYSQL_TIME *time_res, ok: part1=(long) (nr/LL(1000000)); part2=(long) (nr - (longlong) part1*LL(1000000)); + time_res->neg= 0; time_res->year= (int) (part1/10000L); part1%=10000L; time_res->month= (int) part1 / 100; time_res->day= (int) part1 % 100; @@ -1156,7 +1184,7 @@ ulonglong TIME_to_ulonglong_datetime(const MYSQL_TIME *my_time) } -/* Convert TIME value to integer in YYYYMMDD format */ +/* Convert MYSQL_TIME value to integer in YYYYMMDD format */ ulonglong TIME_to_ulonglong_date(const MYSQL_TIME *my_time) { @@ -1166,7 +1194,7 @@ ulonglong TIME_to_ulonglong_date(const MYSQL_TIME *my_time) /* - Convert TIME value to integer in HHMMSS format. + Convert MYSQL_TIME value to integer in HHMMSS format. This function doesn't take into account time->day member: it's assumed that days have been converted to hours already. */ @@ -1180,7 +1208,7 @@ ulonglong TIME_to_ulonglong_time(const MYSQL_TIME *my_time) /* - Convert struct TIME (date and time split into year/month/day/hour/... + Convert struct MYSQL_TIME (date and time split into year/month/day/hour/... to a number in format YYYYMMDDHHMMSS (DATETIME), YYYYMMDD (DATE) or HHMMSS (TIME). @@ -1194,7 +1222,7 @@ ulonglong TIME_to_ulonglong_time(const MYSQL_TIME *my_time) SELECT ?+1; NOTE - This function doesn't check that given TIME structure members are + This function doesn't check that given MYSQL_TIME structure members are in valid range. If they are not, return value won't reflect any valid date either. */ |