~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/time_functions.h

  • Committer: Monty Taylor
  • Date: 2010-12-27 19:41:48 UTC
  • mfrom: (2035 staging)
  • mto: This revision was merged to the branch mainline in revision 2038.
  • Revision ID: mordred@inaugust.com-20101227194148-nqd86au4o76pdltw
Merged trunk.

Show diffs side-by-side

added added

removed removed

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