~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/time_functions.h

  • Committer: Lee Bieber
  • Date: 2011-03-29 22:31:41 UTC
  • mfrom: (2257.1.3 build)
  • Revision ID: kalebral@gmail.com-20110329223141-yxc22h3l2he58sk0
Merge Andrew - 743842: Build failure using GCC 4.6
Merge Stewart - 738022: CachedDirectory silently fails to add entries if stat() fails
Merge Olaf - Common fwd: add copyright, add more declaration

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
18
 */
19
19
 
20
 
#ifndef DRIZZLED_TIME_FUNCTIONS_H
21
 
#define DRIZZLED_TIME_FUNCTIONS_H
 
20
#pragma once
22
21
 
23
 
#include "drizzled/sql_error.h"
24
 
#include "drizzled/drizzle_time.h"
 
22
#include <drizzled/sql_error.h>
 
23
#include <drizzled/type/time.h>
25
24
 
26
25
namespace drizzled
27
26
{
28
 
 
29
 
typedef struct st_drizzle_time DRIZZLE_TIME;
30
 
 
31
27
/* Calc weekday from daynr */
32
28
/* Returns 0 for monday, 1 for tuesday .... */
33
29
int calc_weekday(long daynr, bool sunday_first_day_of_week);
60
56
        Otherwise it is the last week of the previous year, and the
61
57
        next week is week 1.
62
58
*/
63
 
uint32_t calc_week(DRIZZLE_TIME *l_time, uint32_t week_behaviour, uint32_t *year);
 
59
uint32_t calc_week(type::Time *l_time, uint32_t week_behaviour, uint32_t *year);
64
60
 
65
61
/* Change a daynr to year, month and day */
66
62
/* Daynr 0 is returned as date 00.00.00 */
70
66
                         uint32_t *day);
71
67
 
72
68
/*
73
 
  Convert a timestamp string to a DRIZZLE_TIME value and produce a warning
 
69
  Convert a timestamp string to a type::Time value and produce a warning
74
70
  if string was truncated during conversion.
75
71
 
76
72
  NOTE
77
73
    See description of str_to_datetime() for more information.
78
74
*/
79
 
enum enum_drizzle_timestamp_type str_to_datetime_with_warn(const char *str, 
80
 
                                                           uint32_t length,
81
 
                                                           DRIZZLE_TIME *l_time, 
82
 
                                                           uint32_t flags);
 
75
type::timestamp_t str_to_datetime_with_warn(Session *session,
 
76
                                            const char *str, 
 
77
                                            uint32_t length,
 
78
                                            type::Time *l_time, 
 
79
                                            uint32_t flags);
83
80
 
84
81
/*
85
 
  Convert a time string to a DRIZZLE_TIME struct and produce a warning
 
82
  Convert a time string to a type::Time struct and produce a warning
86
83
  if string was cut during conversion.
87
84
 
88
85
  NOTE
89
86
    See str_to_time() for more info.
90
87
*/
91
 
bool str_to_time_with_warn(const char *str, uint32_t length, DRIZZLE_TIME *l_time);
92
 
 
93
 
/*
94
 
  Convert a system time structure to TIME
95
 
*/
96
 
void localtime_to_TIME(DRIZZLE_TIME *to, struct tm *from);
97
 
 
98
 
void make_date(const DRIZZLE_TIME *l_time, String *str);
99
 
 
100
 
void make_datetime(const DRIZZLE_TIME *l_time, String *str);
 
88
bool str_to_time_with_warn(Session *session, const char *str, uint32_t length, type::Time *l_time);
101
89
 
102
90
void make_truncated_value_warning(Session *session, 
103
91
                                  DRIZZLE_ERROR::enum_warning_level level,
104
92
                                  const char *str_val,
105
93
                                  uint32_t str_length, 
106
 
                                  enum enum_drizzle_timestamp_type time_type,
 
94
                                  type::timestamp_t time_type,
107
95
                                  const char *field_name);
108
96
 
109
97
/*
123
111
  NOTE
124
112
    This function calculates difference between l_time1 and l_time2 absolute
125
113
    values. So one should set l_sign and correct result if he want to take
126
 
    signs into account (i.e. for DRIZZLE_TIME values).
 
114
    signs into account (i.e. for type::Time values).
127
115
 
128
116
  RETURN VALUES
129
117
    Returns sign of difference.
131
119
    0 means positive result
132
120
 
133
121
*/
134
 
bool calc_time_diff(DRIZZLE_TIME *l_time1, 
135
 
                    DRIZZLE_TIME *l_time2, 
 
122
bool calc_time_diff(type::Time *l_time1, 
 
123
                    type::Time *l_time2, 
136
124
                    int l_sign,
137
125
                    int64_t *seconds_out, 
138
126
                    long *microseconds_out);
139
127
 
140
128
} /* namespace drizzled */
141
129
 
142
 
#endif /* DRIZZLED_TIME_FUNCTIONS_H */