mysql_time.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /* Copyright (C) 2004 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
  2. This program is free software; you can redistribute it and/or modify
  3. it under the terms of the GNU General Public License as published by
  4. the Free Software Foundation; either version 2 of the License, or
  5. (at your option) any later version.
  6. This program is distributed in the hope that it will be useful,
  7. but WITHOUT ANY WARRANTY; without even the implied warranty of
  8. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  9. GNU General Public License for more details.
  10. You should have received a copy of the GNU General Public License
  11. along with this program; if not, write to the Free Software
  12. Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
  13. #ifndef _mysql_time_h_
  14. #define _mysql_time_h_
  15. /*
  16. Time declarations shared between the server and client API:
  17. you should not add anything to this header unless it's used
  18. (and hence should be visible) in mysql.h.
  19. If you're looking for a place to add new time-related declaration,
  20. it's most likely my_time.h. See also "C API Handling of Date
  21. and Time Values" chapter in documentation.
  22. */
  23. enum enum_mysql_timestamp_type
  24. {
  25. MYSQL_TIMESTAMP_NONE= -2, MYSQL_TIMESTAMP_ERROR= -1,
  26. MYSQL_TIMESTAMP_DATE= 0, MYSQL_TIMESTAMP_DATETIME= 1, MYSQL_TIMESTAMP_TIME= 2
  27. };
  28. /*
  29. Structure which is used to represent datetime values inside MySQL.
  30. We assume that values in this structure are normalized, i.e. year <= 9999,
  31. month <= 12, day <= 31, hour <= 23, hour <= 59, hour <= 59. Many functions
  32. in server such as my_system_gmt_sec() or make_time() family of functions
  33. rely on this (actually now usage of make_*() family relies on a bit weaker
  34. restriction). Also functions that produce MYSQL_TIME as result ensure this.
  35. There is one exception to this rule though if this structure holds time
  36. value (time_type == MYSQL_TIMESTAMP_TIME) days and hour member can hold
  37. bigger values.
  38. */
  39. typedef struct st_mysql_time
  40. {
  41. unsigned int year, month, day, hour, minute, second;
  42. unsigned long second_part;
  43. my_bool neg;
  44. enum enum_mysql_timestamp_type time_type;
  45. } MYSQL_TIME;
  46. #endif /* _mysql_time_h_ */