~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/time_functions.h

  • Committer: Brian Aker
  • Date: 2010-12-27 20:04:50 UTC
  • mto: (2060.2.1 clean)
  • mto: This revision was merged to the branch mainline in revision 2063.
  • Revision ID: brian@tangent.org-20101227200450-dmxpemwyfmlinlnm
Merge in first pass.

Show diffs side-by-side

added added

removed removed

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