| 1 | /* Copyright (c) 2004, 2006 MySQL AB |
| 2 | Use is subject to license terms |
| 3 | |
| 4 | This program is free software; you can redistribute it and/or modify |
| 5 | it under the terms of the GNU General Public License as published by |
| 6 | the Free Software Foundation; version 2 of the License. |
| 7 | |
| 8 | This program is distributed in the hope that it will be useful, |
| 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 11 | GNU General Public License for more details. |
| 12 | |
| 13 | You should have received a copy of the GNU General Public License |
| 14 | along with this program; if not, write to the Free Software |
| 15 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ |
| 16 | |
| 17 | #ifndef _mysql_time_h_ |
| 18 | #define _mysql_time_h_ |
| 19 | |
| 20 | /* |
| 21 | Portable time_t replacement. |
| 22 | Should be signed and hold seconds for 1902 -- 2038-01-19 range |
| 23 | i.e at least a 32bit variable |
| 24 | |
| 25 | Using the system built in time_t is not an option as |
| 26 | we rely on the above requirements in the time functions |
| 27 | */ |
| 28 | typedef long my_time_t; |
| 29 | |
| 30 | |
| 31 | /* |
| 32 | Time declarations shared between the server and client API: |
| 33 | you should not add anything to this header unless it's used |
| 34 | (and hence should be visible) in mysql.h. |
| 35 | If you're looking for a place to add new time-related declaration, |
| 36 | it's most likely my_time.h. See also "C API Handling of Date |
| 37 | and Time Values" chapter in documentation. |
| 38 | */ |
| 39 | |
| 40 | enum enum_mysql_timestamp_type |
| 41 | { |
| 42 | MYSQL_TIMESTAMP_NONE= -2, MYSQL_TIMESTAMP_ERROR= -1, |
| 43 | MYSQL_TIMESTAMP_DATE= 0, MYSQL_TIMESTAMP_DATETIME= 1, MYSQL_TIMESTAMP_TIME= 2 |
| 44 | }; |
| 45 | |
| 46 | |
| 47 | /* |
| 48 | Structure which is used to represent datetime values inside MySQL. |
| 49 | |
| 50 | We assume that values in this structure are normalized, i.e. year <= 9999, |
| 51 | month <= 12, day <= 31, hour <= 23, hour <= 59, hour <= 59. Many functions |
| 52 | in server such as my_system_gmt_sec() or make_time() family of functions |
| 53 | rely on this (actually now usage of make_*() family relies on a bit weaker |
| 54 | restriction). Also functions that produce MYSQL_TIME as result ensure this. |
| 55 | There is one exception to this rule though if this structure holds time |
| 56 | value (time_type == MYSQL_TIMESTAMP_TIME) days and hour member can hold |
| 57 | bigger values. |
| 58 | */ |
| 59 | typedef struct st_mysql_time |
| 60 | { |
| 61 | unsigned int year, month, day, hour, minute, second; |
| 62 | unsigned long second_part; |
| 63 | my_bool neg; |
| 64 | enum enum_mysql_timestamp_type time_type; |
| 65 | } MYSQL_TIME; |
| 66 | |
| 67 | #endif /* _mysql_time_h_ */ |
| 68 | |