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/functions/time/week.h>
26
The bits in week_format(for calc_week() function) has the following meaning:
27
WEEK_MONDAY_FIRST (0) If not set Sunday is first day of week
28
If set Monday is first day of week
29
WEEK_YEAR (1) If not set Week is in range 0-53
31
Week 0 is returned for the the last week of the previous year (for
32
a date at start of january) In this case one can get 53 for the
33
first week of next year. This flag ensures that the week is
34
relevant for the given year. Note that this flag is only
35
releveant if WEEK_JANUARY is not set.
37
If set Week is in range 1-53.
39
In this case one may get week 53 for a date in January (when
40
the week is that last week of previous year) and week 1 for a
43
WEEK_FIRST_WEEKDAY (2) If not set Weeks are numbered according
45
If set The week that contains the first
46
'first-day-of-week' is week 1.
48
ISO 8601:1988 means that if the week containing January 1 has
49
four or more days in the new year, then it is week 1;
50
Otherwise it is the last week of the previous year, and the
55
int64_t Item_func_week::val_int()
60
if (get_arg0_date(<ime, TIME_NO_ZERO_DATE))
62
return (int64_t) calc_week(<ime,
63
week_mode((uint) args[1]->val_int()),