1
1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
2
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
4
* Copyright (C) 2008-2009 Sun Microsystems, Inc.
4
* Copyright (C) 2008-2009 Sun Microsystems
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
21
21
#define DRIZZLED_TIME_FUNCTIONS_H
23
23
#include "drizzled/sql_error.h"
24
#include "drizzled/type/time.h"
24
#include "drizzled/drizzle_time.h"
29
typedef struct st_drizzle_time DRIZZLE_TIME;
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.
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);
62
65
/* Change a daynr to year, month and day */
63
66
/* Daynr 0 is returned as date 00.00.00 */
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.
74
77
See description of str_to_datetime() for more information.
76
type::timestamp_t str_to_datetime_with_warn(Session *session,
79
enum enum_drizzle_timestamp_type str_to_datetime_with_warn(const char *str,
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.
87
89
See str_to_time() for more info.
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);
94
Convert a system time structure to TIME
96
void localtime_to_TIME(DRIZZLE_TIME *to, struct tm *from);
98
void make_date(const DRIZZLE_TIME *l_time, String *str);
100
void make_datetime(const DRIZZLE_TIME *l_time, String *str);
91
102
void make_truncated_value_warning(Session *session,
92
103
DRIZZLE_ERROR::enum_warning_level level,
93
104
const char *str_val,
94
105
uint32_t str_length,
95
type::timestamp_t time_type,
106
enum enum_drizzle_timestamp_type time_type,
96
107
const char *field_name);
113
124
This function calculates difference between l_time1 and l_time2 absolute
114
125
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).
126
signs into account (i.e. for DRIZZLE_TIME values).
118
129
Returns sign of difference.