You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

186 lines
5.6 KiB

16 years ago
21 years ago
17 years ago
  1. /*
  2. +----------------------------------------------------------------------+
  3. | PHP Version 5 |
  4. +----------------------------------------------------------------------+
  5. | Copyright (c) 1997-2011 The PHP Group |
  6. +----------------------------------------------------------------------+
  7. | This source file is subject to version 3.01 of the PHP license, |
  8. | that is bundled with this package in the file LICENSE, and is |
  9. | available through the world-wide-web at the following url: |
  10. | http://www.php.net/license/3_01.txt |
  11. | If you did not receive a copy of the PHP license and are unable to |
  12. | obtain it through the world-wide-web, please send a note to |
  13. | license@php.net so we can mail you a copy immediately. |
  14. +----------------------------------------------------------------------+
  15. | Authors: Derick Rethans <derick@derickrethans.nl> |
  16. +----------------------------------------------------------------------+
  17. */
  18. /* $Id$ */
  19. #ifndef PHP_DATE_H
  20. #define PHP_DATE_H
  21. #include "lib/timelib.h"
  22. #include "Zend/zend_hash.h"
  23. extern zend_module_entry date_module_entry;
  24. #define phpext_date_ptr &date_module_entry
  25. PHP_FUNCTION(date);
  26. PHP_FUNCTION(idate);
  27. PHP_FUNCTION(gmdate);
  28. PHP_FUNCTION(strtotime);
  29. PHP_FUNCTION(mktime);
  30. PHP_FUNCTION(gmmktime);
  31. PHP_FUNCTION(checkdate);
  32. #ifdef HAVE_STRFTIME
  33. PHP_FUNCTION(strftime);
  34. PHP_FUNCTION(gmstrftime);
  35. #endif
  36. PHP_FUNCTION(time);
  37. PHP_FUNCTION(localtime);
  38. PHP_FUNCTION(getdate);
  39. /* Advanced Interface */
  40. PHP_METHOD(DateTime, __construct);
  41. PHP_METHOD(DateTime, __wakeup);
  42. PHP_METHOD(DateTime, __set_state);
  43. PHP_FUNCTION(date_create);
  44. PHP_FUNCTION(date_create_from_format);
  45. PHP_FUNCTION(date_parse);
  46. PHP_FUNCTION(date_parse_from_format);
  47. PHP_FUNCTION(date_get_last_errors);
  48. PHP_FUNCTION(date_format);
  49. PHP_FUNCTION(date_modify);
  50. PHP_FUNCTION(date_add);
  51. PHP_FUNCTION(date_sub);
  52. PHP_FUNCTION(date_timezone_get);
  53. PHP_FUNCTION(date_timezone_set);
  54. PHP_FUNCTION(date_offset_get);
  55. PHP_FUNCTION(date_diff);
  56. PHP_FUNCTION(date_time_set);
  57. PHP_FUNCTION(date_date_set);
  58. PHP_FUNCTION(date_isodate_set);
  59. PHP_FUNCTION(date_timestamp_set);
  60. PHP_FUNCTION(date_timestamp_get);
  61. PHP_METHOD(DateTimeZone, __construct);
  62. PHP_FUNCTION(timezone_open);
  63. PHP_FUNCTION(timezone_name_get);
  64. PHP_FUNCTION(timezone_name_from_abbr);
  65. PHP_FUNCTION(timezone_offset_get);
  66. PHP_FUNCTION(timezone_transitions_get);
  67. PHP_FUNCTION(timezone_location_get);
  68. PHP_FUNCTION(timezone_identifiers_list);
  69. PHP_FUNCTION(timezone_abbreviations_list);
  70. PHP_FUNCTION(timezone_version_get);
  71. PHP_METHOD(DateInterval, __construct);
  72. PHP_FUNCTION(date_interval_format);
  73. PHP_FUNCTION(date_interval_create_from_date_string);
  74. PHP_METHOD(DatePeriod, __construct);
  75. /* Options and Configuration */
  76. PHP_FUNCTION(date_default_timezone_set);
  77. PHP_FUNCTION(date_default_timezone_get);
  78. /* Astro functions */
  79. PHP_FUNCTION(date_sunrise);
  80. PHP_FUNCTION(date_sunset);
  81. PHP_FUNCTION(date_sun_info);
  82. PHP_RINIT_FUNCTION(date);
  83. PHP_RSHUTDOWN_FUNCTION(date);
  84. PHP_MINIT_FUNCTION(date);
  85. PHP_MSHUTDOWN_FUNCTION(date);
  86. PHP_MINFO_FUNCTION(date);
  87. typedef struct _php_date_obj php_date_obj;
  88. typedef struct _php_timezone_obj php_timezone_obj;
  89. typedef struct _php_interval_obj php_interval_obj;
  90. typedef struct _php_period_obj php_period_obj;
  91. struct _php_date_obj {
  92. zend_object std;
  93. timelib_time *time;
  94. HashTable *props;
  95. };
  96. struct _php_timezone_obj {
  97. zend_object std;
  98. int initialized;
  99. int type;
  100. union {
  101. timelib_tzinfo *tz; /* TIMELIB_ZONETYPE_ID; */
  102. timelib_sll utc_offset; /* TIMELIB_ZONETYPE_OFFSET */
  103. struct /* TIMELIB_ZONETYPE_ABBR */
  104. {
  105. timelib_sll utc_offset;
  106. char *abbr;
  107. int dst;
  108. } z;
  109. } tzi;
  110. };
  111. struct _php_interval_obj {
  112. zend_object std;
  113. timelib_rel_time *diff;
  114. HashTable *props;
  115. int initialized;
  116. };
  117. struct _php_period_obj {
  118. zend_object std;
  119. timelib_time *start;
  120. timelib_time *current;
  121. timelib_time *end;
  122. timelib_rel_time *interval;
  123. int recurrences;
  124. int initialized;
  125. int include_start_date;
  126. };
  127. ZEND_BEGIN_MODULE_GLOBALS(date)
  128. char *default_timezone;
  129. char *timezone;
  130. HashTable *tzcache;
  131. timelib_error_container *last_errors;
  132. ZEND_END_MODULE_GLOBALS(date)
  133. #ifdef ZTS
  134. #define DATEG(v) TSRMG(date_globals_id, zend_date_globals *, v)
  135. #else
  136. #define DATEG(v) (date_globals.v)
  137. #endif
  138. /* Backwards compability wrapper */
  139. PHPAPI signed long php_parse_date(char *string, signed long *now);
  140. PHPAPI void php_mktime(INTERNAL_FUNCTION_PARAMETERS, int gmt);
  141. PHPAPI int php_idate(char format, time_t ts, int localtime TSRMLS_DC);
  142. #if HAVE_STRFTIME
  143. #define _php_strftime php_strftime
  144. PHPAPI void php_strftime(INTERNAL_FUNCTION_PARAMETERS, int gm);
  145. #endif
  146. PHPAPI char *php_format_date(char *format, int format_len, time_t ts, int localtime TSRMLS_DC);
  147. /* Mechanism to set new TZ database */
  148. PHPAPI void php_date_set_tzdb(timelib_tzdb *tzdb);
  149. PHPAPI timelib_tzinfo *get_timezone_info(TSRMLS_D);
  150. /* Grabbing CE's so that other exts can use the date objects too */
  151. PHPAPI zend_class_entry *php_date_get_date_ce(void);
  152. PHPAPI zend_class_entry *php_date_get_timezone_ce(void);
  153. /* Functions for creating DateTime objects, and initializing them from a string */
  154. PHPAPI zval *php_date_instantiate(zend_class_entry *pce, zval *object TSRMLS_DC);
  155. PHPAPI int php_date_initialize(php_date_obj *dateobj, /*const*/ char *time_str, int time_str_len, char *format, zval *timezone_object, int ctor TSRMLS_DC);
  156. #endif /* PHP_DATE_H */