diff options
author | monty@mashka.mysql.fi <> | 2002-11-21 15:56:48 +0200 |
---|---|---|
committer | monty@mashka.mysql.fi <> | 2002-11-21 15:56:48 +0200 |
commit | dac6498f9b5b28d94473baf46c6e6f174943728d (patch) | |
tree | d3df5d3fc1abf364dcbcc8eb2305a1cf62540192 /sql/item_timefunc.cc | |
parent | 305d16a7cb3955c20ab5d119b3eb0968008683b6 (diff) | |
parent | e60050c4dd652c7a431aebeb95b7dd944be87bf8 (diff) | |
download | mariadb-git-dac6498f9b5b28d94473baf46c6e6f174943728d.tar.gz |
Merge with 4.0
Diffstat (limited to 'sql/item_timefunc.cc')
-rw-r--r-- | sql/item_timefunc.cc | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/sql/item_timefunc.cc b/sql/item_timefunc.cc index cec83428e24..7c085a1b25a 100644 --- a/sql/item_timefunc.cc +++ b/sql/item_timefunc.cc @@ -198,15 +198,28 @@ longlong Item_func_second::val_int() } -// Returns the week of year in the range of 0 - 53 +/* + Returns the week of year. + + The bits in week_format has the following meaning: + 0 If not set: USA format: Sunday is first day of week + If set: ISO format: Monday is first day of week + 1 If not set: Week is in range 0-53 + If set Week is in range 1-53. +*/ longlong Item_func_week::val_int() { uint year; + uint week_format; TIME ltime; if (get_arg0_date(<ime,0)) return 0; - return (longlong) calc_week(<ime, 0, args[1]->val_int() == 0, &year); + week_format= (uint) args[1]->val_int(); + return (longlong) calc_week(<ime, + (week_format & 2) != 0, + (week_format & 1) == 0, + &year); } @@ -216,7 +229,7 @@ longlong Item_func_yearweek::val_int() TIME ltime; if (get_arg0_date(<ime,0)) return 0; - week=calc_week(<ime, 1, args[1]->val_int() == 0, &year); + week=calc_week(<ime, 1, (args[1]->val_int() & 1) == 0, &year); return week+year*100; } |