The world's most popular open source database
00001 /* Copyright (C) 2004 MySQL AB & MySQL Finland AB & TCX DataKonsult AB 00002 00003 This program is free software; you can redistribute it and/or modify 00004 it under the terms of the GNU General Public License as published by 00005 the Free Software Foundation; either version 2 of the License, or 00006 (at your option) any later version. 00007 00008 This program is distributed in the hope that it will be useful, 00009 but WITHOUT ANY WARRANTY; without even the implied warranty of 00010 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00011 GNU General Public License for more details. 00012 00013 You should have received a copy of the GNU General Public License 00014 along with this program; if not, write to the Free Software 00015 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ 00016 00017 /* 00018 This is a private header of sql-common library, containing 00019 declarations for my_time.c 00020 */ 00021 00022 #ifndef _my_time_h_ 00023 #define _my_time_h_ 00024 #include "my_global.h" 00025 #include "mysql_time.h" 00026 00027 C_MODE_START 00028 00029 extern ulonglong log_10_int[20]; 00030 extern uchar days_in_month[]; 00031 00032 /* 00033 Portable time_t replacement. 00034 Should be signed and hold seconds for 1902-2038 range. 00035 */ 00036 typedef long my_time_t; 00037 00038 #define MY_TIME_T_MAX LONG_MAX 00039 #define MY_TIME_T_MIN LONG_MIN 00040 00041 /* two-digit years < this are 20..; >= this are 19.. */ 00042 #define YY_PART_YEAR 70 00043 /* apply above magic to years < this */ 00044 #define YY_MAGIC_BELOW 200 00045 00046 /* Flags to str_to_datetime */ 00047 #define TIME_FUZZY_DATE 1 00048 #define TIME_DATETIME_ONLY 2 00049 /* Must be same as MODE_NO_ZERO_IN_DATE */ 00050 #define TIME_NO_ZERO_IN_DATE (65536L*2*2*2*2*2*2*2) 00051 /* Must be same as MODE_NO_ZERO_DATE */ 00052 #define TIME_NO_ZERO_DATE (TIME_NO_ZERO_IN_DATE*2) 00053 #define TIME_INVALID_DATES (TIME_NO_ZERO_DATE*2) 00054 00055 enum enum_mysql_timestamp_type 00056 str_to_datetime(const char *str, uint length, MYSQL_TIME *l_time, 00057 uint flags, int *was_cut); 00058 longlong number_to_datetime(longlong nr, MYSQL_TIME *time_res, 00059 uint flags, int *was_cut); 00060 ulonglong TIME_to_ulonglong_datetime(const MYSQL_TIME *time); 00061 ulonglong TIME_to_ulonglong_date(const MYSQL_TIME *time); 00062 ulonglong TIME_to_ulonglong_time(const MYSQL_TIME *time); 00063 ulonglong TIME_to_ulonglong(const MYSQL_TIME *time); 00064 00065 00066 my_bool str_to_time(const char *str,uint length, MYSQL_TIME *l_time, 00067 int *was_cut); 00068 00069 long calc_daynr(uint year,uint month,uint day); 00070 uint calc_days_in_year(uint year); 00071 00072 void init_time(void); 00073 00074 my_time_t 00075 my_system_gmt_sec(const MYSQL_TIME *t, long *my_timezone, 00076 my_bool *in_dst_time_gap); 00077 00078 void set_zero_time(MYSQL_TIME *tm, enum enum_mysql_timestamp_type time_type); 00079 00080 /* 00081 Required buffer length for my_time_to_str, my_date_to_str, 00082 my_datetime_to_str and TIME_to_string functions. Note, that the 00083 caller is still responsible to check that given TIME structure 00084 has values in valid ranges, otherwise size of the buffer could 00085 be not enough. We also rely on the fact that even wrong values 00086 sent using binary protocol fit in this buffer. 00087 */ 00088 #define MAX_DATE_STRING_REP_LENGTH 30 00089 00090 int my_time_to_str(const MYSQL_TIME *l_time, char *to); 00091 int my_date_to_str(const MYSQL_TIME *l_time, char *to); 00092 int my_datetime_to_str(const MYSQL_TIME *l_time, char *to); 00093 int my_TIME_to_str(const MYSQL_TIME *l_time, char *to); 00094 00095 /* 00096 The following must be sorted so that simple intervals comes first. 00097 (get_interval_value() depends on this) 00098 */ 00099 00100 enum interval_type 00101 { 00102 INTERVAL_YEAR, INTERVAL_QUARTER, INTERVAL_MONTH, INTERVAL_DAY, INTERVAL_HOUR, 00103 INTERVAL_MINUTE, INTERVAL_WEEK, INTERVAL_SECOND, INTERVAL_MICROSECOND , 00104 INTERVAL_YEAR_MONTH, INTERVAL_DAY_HOUR, INTERVAL_DAY_MINUTE, 00105 INTERVAL_DAY_SECOND, INTERVAL_HOUR_MINUTE, INTERVAL_HOUR_SECOND, 00106 INTERVAL_MINUTE_SECOND, INTERVAL_DAY_MICROSECOND, INTERVAL_HOUR_MICROSECOND, 00107 INTERVAL_MINUTE_MICROSECOND, INTERVAL_SECOND_MICROSECOND, INTERVAL_LAST 00108 }; 00109 00110 C_MODE_END 00111 00112 #endif /* _my_time_h_ */
1.4.7

