1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
4
* Copyright (C) 2008 Sun Microsystems
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; version 2 of the License.
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License
16
* along with this program; if not, write to the Free Software
17
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20
#include <drizzled/server_includes.h>
22
#include <drizzled/function/time/week.h>
23
#include <drizzled/function/time/week_mode.h>
27
The bits in week_format(for calc_week() function) has the following meaning:
28
WEEK_MONDAY_FIRST (0) If not set Sunday is first day of week
29
If set Monday is first day of week
30
WEEK_YEAR (1) If not set Week is in range 0-53
32
Week 0 is returned for the the last week of the previous year (for
33
a date at start of january) In this case one can get 53 for the
34
first week of next year. This flag ensures that the week is
35
relevant for the given year. Note that this flag is only
36
releveant if WEEK_JANUARY is not set.
38
If set Week is in range 1-53.
40
In this case one may get week 53 for a date in January (when
41
the week is that last week of previous year) and week 1 for a
44
WEEK_FIRST_WEEKDAY (2) If not set Weeks are numbered according
46
If set The week that contains the first
47
'first-day-of-week' is week 1.
49
ISO 8601:1988 means that if the week containing January 1 has
50
four or more days in the new year, then it is week 1;
51
Otherwise it is the last week of the previous year, and the
56
int64_t Item_func_week::val_int()
61
if (get_arg0_date(<ime, TIME_NO_ZERO_DATE))
63
return (int64_t) calc_week(<ime,
64
week_mode((uint) args[1]->val_int()),