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 |
||
1237.9.8
by Monty Taylor
Fixed solaris build. |
20 |
#ifndef DRIZZLED_TIME_FUNCTIONS_H
|
21 |
#define DRIZZLED_TIME_FUNCTIONS_H
|
|
1237.9.4
by Padraig O'Sullivan
Removed the inclusion of drizzled/field.h in the server_includes header file. |
22 |
|
23 |
#include "drizzled/sql_error.h" |
|
2032
by Brian Aker
MErge in the include changes. |
24 |
#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. |
25 |
|
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
26 |
namespace drizzled |
27 |
{
|
|
1237.9.4
by Padraig O'Sullivan
Removed the inclusion of drizzled/field.h in the server_includes header file. |
28 |
/* Calc weekday from daynr */
|
29 |
/* Returns 0 for monday, 1 for tuesday .... */
|
|
30 |
int calc_weekday(long daynr, bool sunday_first_day_of_week); |
|
31 |
||
32 |
/*
|
|
33 |
The bits in week_format has the following meaning:
|
|
34 |
WEEK_MONDAY_FIRST (0) If not set Sunday is first day of week
|
|
35 |
If set Monday is first day of week
|
|
36 |
WEEK_YEAR (1) If not set Week is in range 0-53
|
|
37 |
||
38 |
Week 0 is returned for the the last week of the previous year (for
|
|
39 |
a date at start of january) In this case one can get 53 for the
|
|
40 |
first week of next year. This flag ensures that the week is
|
|
41 |
relevant for the given year. Note that this flag is only
|
|
42 |
releveant if WEEK_JANUARY is not set.
|
|
43 |
||
44 |
If set Week is in range 1-53.
|
|
45 |
||
46 |
In this case one may get week 53 for a date in January (when
|
|
47 |
the week is that last week of previous year) and week 1 for a
|
|
48 |
date in December.
|
|
49 |
||
50 |
WEEK_FIRST_WEEKDAY (2) If not set Weeks are numbered according
|
|
51 |
to ISO 8601:1988
|
|
52 |
If set The week that contains the first
|
|
53 |
'first-day-of-week' is week 1.
|
|
54 |
||
55 |
ISO 8601:1988 means that if the week containing January 1 has
|
|
56 |
four or more days in the new year, then it is week 1;
|
|
57 |
Otherwise it is the last week of the previous year, and the
|
|
58 |
next week is week 1.
|
|
59 |
*/
|
|
2030.1.5
by Brian Aker
Update for moving DRIZZLE_TIME to type::Time |
60 |
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. |
61 |
|
62 |
/* Change a daynr to year, month and day */
|
|
63 |
/* Daynr 0 is returned as date 00.00.00 */
|
|
64 |
void get_date_from_daynr(long daynr, |
|
65 |
uint32_t *year, |
|
66 |
uint32_t *month, |
|
67 |
uint32_t *day); |
|
68 |
||
69 |
/*
|
|
2030.1.5
by Brian Aker
Update for moving DRIZZLE_TIME to type::Time |
70 |
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. |
71 |
if string was truncated during conversion.
|
72 |
||
73 |
NOTE
|
|
74 |
See description of str_to_datetime() for more information.
|
|
75 |
*/
|
|
2114.5.1
by Brian Aker
Additional abstract around time (this also makes the abort_on_warnings in |
76 |
type::timestamp_t str_to_datetime_with_warn(Session *session, |
77 |
const char *str, |
|
2088.8.9
by Brian Aker
Merge in namespace of enum. |
78 |
uint32_t length, |
79 |
type::Time *l_time, |
|
80 |
uint32_t flags); |
|
1237.9.4
by Padraig O'Sullivan
Removed the inclusion of drizzled/field.h in the server_includes header file. |
81 |
|
82 |
/*
|
|
2030.1.5
by Brian Aker
Update for moving DRIZZLE_TIME to type::Time |
83 |
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. |
84 |
if string was cut during conversion.
|
85 |
||
86 |
NOTE
|
|
87 |
See str_to_time() for more info.
|
|
88 |
*/
|
|
2030.1.5
by Brian Aker
Update for moving DRIZZLE_TIME to type::Time |
89 |
bool str_to_time_with_warn(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. |
90 |
|
91 |
void make_truncated_value_warning(Session *session, |
|
92 |
DRIZZLE_ERROR::enum_warning_level level, |
|
93 |
const char *str_val, |
|
94 |
uint32_t str_length, |
|
2088.8.9
by Brian Aker
Merge in namespace of enum. |
95 |
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. |
96 |
const char *field_name); |
97 |
||
98 |
/*
|
|
99 |
Calculate difference between two datetime values as seconds + microseconds.
|
|
100 |
||
101 |
SYNOPSIS
|
|
102 |
calc_time_diff()
|
|
103 |
l_time1 - TIME/DATE/DATETIME value
|
|
104 |
l_time2 - TIME/DATE/DATETIME value
|
|
105 |
l_sign - 1 absolute values are substracted,
|
|
106 |
-1 absolute values are added.
|
|
107 |
seconds_out - Out parameter where difference between
|
|
108 |
l_time1 and l_time2 in seconds is stored.
|
|
109 |
microseconds_out- Out parameter where microsecond part of difference
|
|
110 |
between l_time1 and l_time2 is stored.
|
|
111 |
||
112 |
NOTE
|
|
113 |
This function calculates difference between l_time1 and l_time2 absolute
|
|
114 |
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 |
115 |
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. |
116 |
|
117 |
RETURN VALUES
|
|
118 |
Returns sign of difference.
|
|
119 |
1 means negative result
|
|
120 |
0 means positive result
|
|
121 |
||
122 |
*/
|
|
2030.1.5
by Brian Aker
Update for moving DRIZZLE_TIME to type::Time |
123 |
bool calc_time_diff(type::Time *l_time1, |
124 |
type::Time *l_time2, |
|
1237.9.4
by Padraig O'Sullivan
Removed the inclusion of drizzled/field.h in the server_includes header file. |
125 |
int l_sign, |
126 |
int64_t *seconds_out, |
|
127 |
long *microseconds_out); |
|
128 |
||
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
129 |
} /* namespace drizzled */ |
130 |
||
1237.9.8
by Monty Taylor
Fixed solaris build. |
131 |
#endif /* DRIZZLED_TIME_FUNCTIONS_H */ |