diff options
author | unknown <monty@mysql.com> | 2004-11-12 19:58:24 +0200 |
---|---|---|
committer | unknown <monty@mysql.com> | 2004-11-12 19:58:24 +0200 |
commit | 19c2ce47dbe4e79c378e06b09c1543eb875ade51 (patch) | |
tree | e0dd750287073966f1595d8099b4cc23faa803f7 /sql-common/my_time.c | |
parent | 671871d95fe7a66195a229be550d19c2fcf6dd35 (diff) | |
parent | 870b048b8ea84108f3325b1fa455d60123f4fb9e (diff) | |
download | mariadb-git-19c2ce47dbe4e79c378e06b09c1543eb875ade51.tar.gz |
Merge with 4.1
BitKeeper/etc/logging_ok:
auto-union
BitKeeper/deleted/.del-Makefile.am:
Auto merged
BitKeeper/deleted/.del-Makefile.am~1:
Delete: Docs/Images/Makefile.am
client/mysqltest.c:
Auto merged
include/mysql.h:
Auto merged
libmysql/libmysql.c:
Auto merged
myisam/mi_check.c:
Auto merged
mysql-test/r/grant.result:
Auto merged
mysql-test/r/ps_1general.result:
Auto merged
mysql-test/t/grant.test:
Auto merged
mysql-test/t/mix_innodb_myisam_binlog.test:
Auto merged
mysql-test/t/ps_1general.test:
Auto merged
sql/field.cc:
Auto merged
sql/ha_innodb.cc:
Auto merged
sql/mysqld.cc:
Auto merged
sql/share/french/errmsg.txt:
Auto merged
sql/share/greek/errmsg.txt:
Auto merged
sql/sql_acl.cc:
Auto merged
sql/sql_table.cc:
Auto merged
sql/time.cc:
Auto merged
sql-common/my_time.c:
Auto merged
sql/share/portuguese/errmsg.txt:
Auto merged
sql/share/romanian/errmsg.txt:
Auto merged
sql/share/serbian/errmsg.txt:
Auto merged
sql/share/spanish/errmsg.txt:
Auto merged
sql/share/swedish/errmsg.txt:
Auto merged
configure.in:
Merge with 4.0
mysql-test/r/mix_innodb_myisam_binlog.result:
Merge with 4.0
mysys/default.c:
Merge with 4.1 (to get new extension handling)
sql/log.cc:
Merge with 4.0
tests/client_test.c:
Merge with 4.1 (to get possibility to run any tests)
Diffstat (limited to 'sql-common/my_time.c')
-rw-r--r-- | sql-common/my_time.c | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/sql-common/my_time.c b/sql-common/my_time.c index dc997921f74..5afa6ea2857 100644 --- a/sql-common/my_time.c +++ b/sql-common/my_time.c @@ -723,6 +723,10 @@ my_system_gmt_sec(const MYSQL_TIME *t, long *my_timezone, bool *in_dst_time_gap) I couldn't come up with a better way to get a repeatable result :( We can't use mktime() as it's buggy on many platforms and not thread safe. + + Note: this code assumes that our time_t estimation is not too far away + from real value (we assume that localtime_r(tmp) will return something + within 24 hrs from t) which is probably true for all current time zones. */ tmp=(time_t) (((calc_daynr((uint) t->year,(uint) t->month,(uint) t->day) - (long) days_at_timestart)*86400L + (long) t->hour*3600L + @@ -735,7 +739,8 @@ my_system_gmt_sec(const MYSQL_TIME *t, long *my_timezone, bool *in_dst_time_gap) for (loop=0; loop < 2 && (t->hour != (uint) l_time->tm_hour || - t->minute != (uint) l_time->tm_min); + t->minute != (uint) l_time->tm_min || + t->second != (uint) l_time->tm_sec); loop++) { /* One check should be enough ? */ /* Get difference in days */ @@ -745,15 +750,22 @@ my_system_gmt_sec(const MYSQL_TIME *t, long *my_timezone, bool *in_dst_time_gap) else if (days > 1) days= -1; diff=(3600L*(long) (days*24+((int) t->hour - (int) l_time->tm_hour)) + - (long) (60*((int) t->minute - (int) l_time->tm_min))); + (long) (60*((int) t->minute - (int) l_time->tm_min)) + + (long) ((int) t->second - (int) l_time->tm_sec)); current_timezone+= diff+3600; /* Compensate for -3600 above */ tmp+= (time_t) diff; localtime_r(&tmp,&tm_tmp); l_time=&tm_tmp; } /* - Fix that if we are in the not existing daylight saving time hour - we move the start of the next real hour + Fix that if we are in the non existing daylight saving time hour + we move the start of the next real hour. + + This code doesn't handle such exotical thing as time-gaps whose length + is more than one hour or non-integer (latter can theoretically happen + if one of seconds will be removed due leap correction, or because of + general time correction like it happened for Africa/Monrovia time zone + in year 1972). */ if (loop == 2 && t->hour != (uint) l_time->tm_hour) { @@ -763,7 +775,8 @@ my_system_gmt_sec(const MYSQL_TIME *t, long *my_timezone, bool *in_dst_time_gap) else if (days > 1) days= -1; diff=(3600L*(long) (days*24+((int) t->hour - (int) l_time->tm_hour))+ - (long) (60*((int) t->minute - (int) l_time->tm_min))); + (long) (60*((int) t->minute - (int) l_time->tm_min)) + + (long) ((int) t->second - (int) l_time->tm_sec)); if (diff == 3600) tmp+=3600 - t->minute*60 - t->second; /* Move to next hour */ else if (diff == -3600) |