~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/time_functions.h

  • Committer: Brian Aker
  • Date: 2011-02-17 10:09:00 UTC
  • mfrom: (2173.2.1 clean-include-usuage)
  • Revision ID: brian@tangent.org-20110217100900-4tpuxxzdl1sj00sh
Merge Monty for headers.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
3
 *
4
 
 *  Copyright (C) 2008-2009 Sun Microsystems
 
4
 *  Copyright (C) 2008-2009 Sun Microsystems, Inc.
5
5
 *
6
6
 *  This program is free software; you can redistribute it and/or modify
7
7
 *  it under the terms of the GNU General Public License as published by
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/drizzle_time.h"
 
23
#include <drizzled/sql_error.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
77
74
    See description of str_to_datetime() for more information.
78
75
*/
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);
 
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);
83
81
 
84
82
/*
85
 
  Convert a time string to a DRIZZLE_TIME struct and produce a warning
 
83
  Convert a time string to a type::Time struct and produce a warning
86
84
  if string was cut during conversion.
87
85
 
88
86
  NOTE
89
87
    See str_to_time() for more info.
90
88
*/
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);
 
89
bool str_to_time_with_warn(Session *session, const char *str, uint32_t length, type::Time *l_time);
101
90
 
102
91
void make_truncated_value_warning(Session *session, 
103
92
                                  DRIZZLE_ERROR::enum_warning_level level,
104
93
                                  const char *str_val,
105
94
                                  uint32_t str_length, 
106
 
                                  enum enum_drizzle_timestamp_type time_type,
 
95
                                  type::timestamp_t time_type,
107
96
                                  const char *field_name);
108
97
 
109
98
/*
123
112
  NOTE
124
113
    This function calculates difference between l_time1 and l_time2 absolute
125
114
    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).
 
115
    signs into account (i.e. for type::Time values).
127
116
 
128
117
  RETURN VALUES
129
118
    Returns sign of difference.
131
120
    0 means positive result
132
121
 
133
122
*/
134
 
bool calc_time_diff(DRIZZLE_TIME *l_time1, 
135
 
                    DRIZZLE_TIME *l_time2, 
 
123
bool calc_time_diff(type::Time *l_time1, 
 
124
                    type::Time *l_time2, 
136
125
                    int l_sign,
137
126
                    int64_t *seconds_out, 
138
127
                    long *microseconds_out);