~drizzle-trunk/drizzle/development

1237.9.4 by Padraig O'Sullivan
Removed the inclusion of drizzled/field.h in the server_includes header file.
1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
 *
1999.6.1 by kalebral at gmail
update Copyright strings to a more common format to help with creating the master debian copyright file
4
 *  Copyright (C) 2008-2009 Sun Microsystems, Inc.
1237.9.4 by Padraig O'Sullivan
Removed the inclusion of drizzled/field.h in the server_includes header file.
5
 *
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.
9
 *
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.
14
 *
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
18
 */
19
2234 by Brian Aker
Mass removal of ifdef/endif in favor of pragma once.
20
#pragma once
1237.9.4 by Padraig O'Sullivan
Removed the inclusion of drizzled/field.h in the server_includes header file.
21
2173.2.1 by Monty Taylor
Fixes incorrect usage of include
22
#include <drizzled/sql_error.h>
23
#include <drizzled/type/time.h>
1237.9.4 by Padraig O'Sullivan
Removed the inclusion of drizzled/field.h in the server_includes header file.
24
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
25
namespace drizzled
26
{
1237.9.4 by Padraig O'Sullivan
Removed the inclusion of drizzled/field.h in the server_includes header file.
27
/* Calc weekday from daynr */
28
/* Returns 0 for monday, 1 for tuesday .... */
29
int calc_weekday(long daynr, bool sunday_first_day_of_week);
30
31
/*
32
  The bits in week_format has the following meaning:
33
   WEEK_MONDAY_FIRST (0)  If not set	Sunday is first day of week
34
      		   	  If set	Monday is first day of week
35
   WEEK_YEAR (1)	  If not set	Week is in range 0-53
36
37
   	Week 0 is returned for the the last week of the previous year (for
38
	a date at start of january) In this case one can get 53 for the
39
	first week of next year.  This flag ensures that the week is
40
	relevant for the given year. Note that this flag is only
41
	releveant if WEEK_JANUARY is not set.
42
43
			  If set	 Week is in range 1-53.
44
45
	In this case one may get week 53 for a date in January (when
46
	the week is that last week of previous year) and week 1 for a
47
	date in December.
48
49
  WEEK_FIRST_WEEKDAY (2)  If not set	Weeks are numbered according
50
			   		to ISO 8601:1988
51
			  If set	The week that contains the first
52
					'first-day-of-week' is week 1.
53
54
	ISO 8601:1988 means that if the week containing January 1 has
55
	four or more days in the new year, then it is week 1;
56
	Otherwise it is the last week of the previous year, and the
57
	next week is week 1.
58
*/
2030.1.5 by Brian Aker
Update for moving DRIZZLE_TIME to type::Time
59
uint32_t calc_week(type::Time *l_time, uint32_t week_behaviour, uint32_t *year);
1237.9.4 by Padraig O'Sullivan
Removed the inclusion of drizzled/field.h in the server_includes header file.
60
61
/* Change a daynr to year, month and day */
62
/* Daynr 0 is returned as date 00.00.00 */
63
void get_date_from_daynr(long daynr,
64
                         uint32_t *year, 
65
                         uint32_t *month,
66
                         uint32_t *day);
67
68
/*
2030.1.5 by Brian Aker
Update for moving DRIZZLE_TIME to type::Time
69
  Convert a timestamp string to a type::Time value and produce a warning
1237.9.4 by Padraig O'Sullivan
Removed the inclusion of drizzled/field.h in the server_includes header file.
70
  if string was truncated during conversion.
71
72
  NOTE
73
    See description of str_to_datetime() for more information.
74
*/
2114.5.1 by Brian Aker
Additional abstract around time (this also makes the abort_on_warnings in
75
type::timestamp_t str_to_datetime_with_warn(Session *session,
76
                                            const char *str, 
2088.8.9 by Brian Aker
Merge in namespace of enum.
77
                                            uint32_t length,
78
                                            type::Time *l_time, 
79
                                            uint32_t flags);
1237.9.4 by Padraig O'Sullivan
Removed the inclusion of drizzled/field.h in the server_includes header file.
80
81
/*
2030.1.5 by Brian Aker
Update for moving DRIZZLE_TIME to type::Time
82
  Convert a time string to a type::Time struct and produce a warning
1237.9.4 by Padraig O'Sullivan
Removed the inclusion of drizzled/field.h in the server_includes header file.
83
  if string was cut during conversion.
84
85
  NOTE
86
    See str_to_time() for more info.
87
*/
2137.1.9 by Brian Aker
Remove current_session usage in one location (we have the table's session to
88
bool str_to_time_with_warn(Session *session, const char *str, uint32_t length, type::Time *l_time);
1237.9.4 by Padraig O'Sullivan
Removed the inclusion of drizzled/field.h in the server_includes header file.
89
90
void make_truncated_value_warning(Session *session, 
91
                                  DRIZZLE_ERROR::enum_warning_level level,
92
                                  const char *str_val,
93
                                  uint32_t str_length, 
2088.8.9 by Brian Aker
Merge in namespace of enum.
94
                                  type::timestamp_t time_type,
1237.9.4 by Padraig O'Sullivan
Removed the inclusion of drizzled/field.h in the server_includes header file.
95
                                  const char *field_name);
96
97
/*
98
  Calculate difference between two datetime values as seconds + microseconds.
99
100
  SYNOPSIS
101
    calc_time_diff()
102
      l_time1         - TIME/DATE/DATETIME value
103
      l_time2         - TIME/DATE/DATETIME value
104
      l_sign          - 1 absolute values are substracted,
105
                        -1 absolute values are added.
106
      seconds_out     - Out parameter where difference between
107
                        l_time1 and l_time2 in seconds is stored.
108
      microseconds_out- Out parameter where microsecond part of difference
109
                        between l_time1 and l_time2 is stored.
110
111
  NOTE
112
    This function calculates difference between l_time1 and l_time2 absolute
113
    values. So one should set l_sign and correct result if he want to take
2030.1.5 by Brian Aker
Update for moving DRIZZLE_TIME to type::Time
114
    signs into account (i.e. for type::Time values).
1237.9.4 by Padraig O'Sullivan
Removed the inclusion of drizzled/field.h in the server_includes header file.
115
116
  RETURN VALUES
117
    Returns sign of difference.
118
    1 means negative result
119
    0 means positive result
120
121
*/
2030.1.5 by Brian Aker
Update for moving DRIZZLE_TIME to type::Time
122
bool calc_time_diff(type::Time *l_time1, 
123
                    type::Time *l_time2, 
1237.9.4 by Padraig O'Sullivan
Removed the inclusion of drizzled/field.h in the server_includes header file.
124
                    int l_sign,
125
                    int64_t *seconds_out, 
126
                    long *microseconds_out);
127
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
128
} /* namespace drizzled */
129