diff options
Diffstat (limited to 'sql/time.cc')
-rw-r--r-- | sql/time.cc | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/sql/time.cc b/sql/time.cc index 1d7e055f682..aab886648e3 100644 --- a/sql/time.cc +++ b/sql/time.cc @@ -1,15 +1,15 @@ /* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB - + This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ @@ -24,7 +24,7 @@ static ulong const days_at_timestart=719528; /* daynr at 1970.01.01 */ uchar *days_in_month= (uchar*) "\037\034\037\036\037\036\037\037\036\037\036\037"; - /* Init some variabels neaded when using my_local_time */ + /* Init some variabels needed when using my_local_time */ /* Currently only my_time_zone is inited */ static long my_time_zone=0; @@ -54,7 +54,7 @@ void init_time(void) This code handles also day light saving time. The idea is to cache the time zone (including daylight saving time) for the next call to make things faster. - + */ long my_gmt_sec(TIME *t) @@ -128,7 +128,7 @@ long calc_daynr(uint year,uint month,uint day) DBUG_ENTER("calc_daynr"); if (year == 0 && month == 0 && day == 0) - DBUG_RETURN(0); /* Skipp errors */ + DBUG_RETURN(0); /* Skip errors */ if (year < 200) { if ((year=year+1900) < 1900+YY_PART_YEAR) @@ -176,7 +176,9 @@ uint calc_week(TIME *l_time, bool with_year, bool sunday_first_day_of_week, ulong first_daynr=calc_daynr(l_time->year,1,1); uint weekday=calc_weekday(first_daynr,sunday_first_day_of_week); *year=l_time->year; - if (l_time->month == 1 && weekday >= 4 && l_time->day <= 7-weekday) + if (l_time->month == 1 && l_time->day <= 7-weekday && + ((!sunday_first_day_of_week && weekday >= 4) || + (sunday_first_day_of_week && weekday != 0))) { /* Last week of the previous year */ if (!with_year) @@ -186,7 +188,8 @@ uint calc_week(TIME *l_time, bool with_year, bool sunday_first_day_of_week, first_daynr-= (days=calc_days_in_year(*year)); weekday= (weekday + 53*7- days) % 7; } - if (weekday >= 4) + if ((sunday_first_day_of_week && weekday != 0) || + (!sunday_first_day_of_week && weekday >= 4)) days= daynr - (first_daynr+ (7-weekday)); else days= daynr - (first_daynr - weekday); @@ -431,7 +434,7 @@ str_to_TIME(const char *str, uint length, TIME *l_time,bool fuzzy_date) DBUG_ENTER("str_to_TIME"); DBUG_PRINT("enter",("str: %.*s",length,str)); - for (; str != end && !isdigit(*str) ; str++) ; // Skipp garbage + for (; str != end && !isdigit(*str) ; str++) ; // Skip garbage if (str == end) DBUG_RETURN(TIMESTAMP_NONE); /* @@ -591,7 +594,7 @@ bool str_to_time(const char *str,uint length,TIME *l_time) date[0]=value; state=1; // Assume next is hours found_days=1; - str++; // Skipp space; + str++; // Skip space; } else if ((end-str) > 1 && *str == ':' && isdigit(str[1])) { @@ -599,7 +602,7 @@ bool str_to_time(const char *str,uint length,TIME *l_time) date[1]=value; state=2; found_hours=1; - str++; // skipp ':' + str++; // skip ':' } else { @@ -620,7 +623,7 @@ bool str_to_time(const char *str,uint length,TIME *l_time) date[state++]=value; if (state == 4 || (end-str) < 2 || *str != ':' || !isdigit(str[1])) break; - str++; // Skipp ':' + str++; // Skip ':' } if (state != 4) |