/ext/date/php_date.h

https://github.com/gmphp/PHP · C Header · 188 lines · 132 code · 31 blank · 25 comment · 0 complexity · a78342d83d4456e9b7ff662885a74742 MD5 · raw file

  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: php_date.h 306939 2011-01-01 02:19:59Z felipe $ */
  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_FUNCTION(timechop);
  83. PHP_RINIT_FUNCTION(date);
  84. PHP_RSHUTDOWN_FUNCTION(date);
  85. PHP_MINIT_FUNCTION(date);
  86. PHP_MSHUTDOWN_FUNCTION(date);
  87. PHP_MINFO_FUNCTION(date);
  88. typedef struct _php_date_obj php_date_obj;
  89. typedef struct _php_timezone_obj php_timezone_obj;
  90. typedef struct _php_interval_obj php_interval_obj;
  91. typedef struct _php_period_obj php_period_obj;
  92. struct _php_date_obj {
  93. zend_object std;
  94. timelib_time *time;
  95. HashTable *props;
  96. };
  97. struct _php_timezone_obj {
  98. zend_object std;
  99. int initialized;
  100. int type;
  101. union {
  102. timelib_tzinfo *tz; /* TIMELIB_ZONETYPE_ID; */
  103. timelib_sll utc_offset; /* TIMELIB_ZONETYPE_OFFSET */
  104. struct /* TIMELIB_ZONETYPE_ABBR */
  105. {
  106. timelib_sll utc_offset;
  107. char *abbr;
  108. int dst;
  109. } z;
  110. } tzi;
  111. };
  112. struct _php_interval_obj {
  113. zend_object std;
  114. timelib_rel_time *diff;
  115. HashTable *props;
  116. int initialized;
  117. };
  118. struct _php_period_obj {
  119. zend_object std;
  120. timelib_time *start;
  121. timelib_time *current;
  122. timelib_time *end;
  123. timelib_rel_time *interval;
  124. int recurrences;
  125. int initialized;
  126. int include_start_date;
  127. };
  128. ZEND_BEGIN_MODULE_GLOBALS(date)
  129. char *default_timezone;
  130. char *timezone;
  131. HashTable *tzcache;
  132. timelib_error_container *last_errors;
  133. ZEND_END_MODULE_GLOBALS(date)
  134. #ifdef ZTS
  135. #define DATEG(v) TSRMG(date_globals_id, zend_date_globals *, v)
  136. #else
  137. #define DATEG(v) (date_globals.v)
  138. #endif
  139. /* Backwards compability wrapper */
  140. PHPAPI signed long php_parse_date(char *string, signed long *now);
  141. PHPAPI void php_mktime(INTERNAL_FUNCTION_PARAMETERS, int gmt);
  142. PHPAPI int php_idate(char format, time_t ts, int localtime);
  143. #if HAVE_STRFTIME
  144. #define _php_strftime php_strftime
  145. PHPAPI void php_strftime(INTERNAL_FUNCTION_PARAMETERS, int gm);
  146. #endif
  147. PHPAPI char *php_format_date(char *format, int format_len, time_t ts, int localtime TSRMLS_DC);
  148. /* Mechanism to set new TZ database */
  149. PHPAPI void php_date_set_tzdb(timelib_tzdb *tzdb);
  150. PHPAPI timelib_tzinfo *get_timezone_info(TSRMLS_D);
  151. /* Grabbing CE's so that other exts can use the date objects too */
  152. PHPAPI zend_class_entry *php_date_get_date_ce(void);
  153. PHPAPI zend_class_entry *php_date_get_timezone_ce(void);
  154. /* Functions for creating DateTime objects, and initializing them from a string */
  155. PHPAPI zval *php_date_instantiate(zend_class_entry *pce, zval *object TSRMLS_DC);
  156. 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);
  157. #endif /* PHP_DATE_H */