PageRenderTime 36ms CodeModel.GetById 12ms RepoModel.GetById 0ms app.codeStats 1ms

/release/src/router/php/ext/date/php_date.h

https://gitlab.com/envieidoc/tomato
C Header | 203 lines | 147 code | 31 blank | 25 comment | 0 complexity | 9b08952e84407c5627d4585d7ce1e711 MD5 | raw file
  1. /*
  2. +----------------------------------------------------------------------+
  3. | PHP Version 5 |
  4. +----------------------------------------------------------------------+
  5. | Copyright (c) 1997-2014 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_immutable);
  45. PHP_FUNCTION(date_create_from_format);
  46. PHP_FUNCTION(date_create_immutable_from_format);
  47. PHP_FUNCTION(date_parse);
  48. PHP_FUNCTION(date_parse_from_format);
  49. PHP_FUNCTION(date_get_last_errors);
  50. PHP_FUNCTION(date_format);
  51. PHP_FUNCTION(date_modify);
  52. PHP_FUNCTION(date_add);
  53. PHP_FUNCTION(date_sub);
  54. PHP_FUNCTION(date_timezone_get);
  55. PHP_FUNCTION(date_timezone_set);
  56. PHP_FUNCTION(date_offset_get);
  57. PHP_FUNCTION(date_diff);
  58. PHP_FUNCTION(date_time_set);
  59. PHP_FUNCTION(date_date_set);
  60. PHP_FUNCTION(date_isodate_set);
  61. PHP_FUNCTION(date_timestamp_set);
  62. PHP_FUNCTION(date_timestamp_get);
  63. PHP_METHOD(DateTimeImmutable, __construct);
  64. PHP_METHOD(DateTimeImmutable, __set_state);
  65. PHP_METHOD(DateTimeImmutable, modify);
  66. PHP_METHOD(DateTimeImmutable, add);
  67. PHP_METHOD(DateTimeImmutable, sub);
  68. PHP_METHOD(DateTimeImmutable, setTimezone);
  69. PHP_METHOD(DateTimeImmutable, setTime);
  70. PHP_METHOD(DateTimeImmutable, setDate);
  71. PHP_METHOD(DateTimeImmutable, setISODate);
  72. PHP_METHOD(DateTimeImmutable, setTimestamp);
  73. PHP_METHOD(DateTimeZone, __construct);
  74. PHP_METHOD(DateTimeZone, __wakeup);
  75. PHP_METHOD(DateTimeZone, __set_state);
  76. PHP_FUNCTION(timezone_open);
  77. PHP_FUNCTION(timezone_name_get);
  78. PHP_FUNCTION(timezone_name_from_abbr);
  79. PHP_FUNCTION(timezone_offset_get);
  80. PHP_FUNCTION(timezone_transitions_get);
  81. PHP_FUNCTION(timezone_location_get);
  82. PHP_FUNCTION(timezone_identifiers_list);
  83. PHP_FUNCTION(timezone_abbreviations_list);
  84. PHP_FUNCTION(timezone_version_get);
  85. PHP_METHOD(DateInterval, __construct);
  86. PHP_METHOD(DateInterval, __wakeup);
  87. PHP_METHOD(DateInterval, __set_state);
  88. PHP_FUNCTION(date_interval_format);
  89. PHP_FUNCTION(date_interval_create_from_date_string);
  90. PHP_METHOD(DatePeriod, __construct);
  91. PHP_METHOD(DatePeriod, __wakeup);
  92. PHP_METHOD(DatePeriod, __set_state);
  93. /* Options and Configuration */
  94. PHP_FUNCTION(date_default_timezone_set);
  95. PHP_FUNCTION(date_default_timezone_get);
  96. /* Astro functions */
  97. PHP_FUNCTION(date_sunrise);
  98. PHP_FUNCTION(date_sunset);
  99. PHP_FUNCTION(date_sun_info);
  100. PHP_RINIT_FUNCTION(date);
  101. PHP_RSHUTDOWN_FUNCTION(date);
  102. PHP_MINIT_FUNCTION(date);
  103. PHP_MSHUTDOWN_FUNCTION(date);
  104. PHP_MINFO_FUNCTION(date);
  105. typedef struct _php_date_obj php_date_obj;
  106. typedef struct _php_timezone_obj php_timezone_obj;
  107. typedef struct _php_interval_obj php_interval_obj;
  108. typedef struct _php_period_obj php_period_obj;
  109. struct _php_date_obj {
  110. zend_object std;
  111. timelib_time *time;
  112. HashTable *props;
  113. };
  114. struct _php_timezone_obj {
  115. zend_object std;
  116. int initialized;
  117. int type;
  118. union {
  119. timelib_tzinfo *tz; /* TIMELIB_ZONETYPE_ID */
  120. timelib_sll utc_offset; /* TIMELIB_ZONETYPE_OFFSET */
  121. timelib_abbr_info z; /* TIMELIB_ZONETYPE_ABBR */
  122. } tzi;
  123. HashTable *props;
  124. };
  125. struct _php_interval_obj {
  126. zend_object std;
  127. timelib_rel_time *diff;
  128. HashTable *props;
  129. int initialized;
  130. };
  131. struct _php_period_obj {
  132. zend_object std;
  133. timelib_time *start;
  134. zend_class_entry *start_ce;
  135. timelib_time *current;
  136. timelib_time *end;
  137. timelib_rel_time *interval;
  138. int recurrences;
  139. int initialized;
  140. int include_start_date;
  141. };
  142. ZEND_BEGIN_MODULE_GLOBALS(date)
  143. char *default_timezone;
  144. char *timezone;
  145. HashTable *tzcache;
  146. timelib_error_container *last_errors;
  147. int timezone_valid;
  148. ZEND_END_MODULE_GLOBALS(date)
  149. #ifdef ZTS
  150. #define DATEG(v) TSRMG(date_globals_id, zend_date_globals *, v)
  151. #else
  152. #define DATEG(v) (date_globals.v)
  153. #endif
  154. /* Backwards compatibility wrapper */
  155. PHPAPI signed long php_parse_date(char *string, signed long *now);
  156. PHPAPI void php_mktime(INTERNAL_FUNCTION_PARAMETERS, int gmt);
  157. PHPAPI int php_idate(char format, time_t ts, int localtime TSRMLS_DC);
  158. #if HAVE_STRFTIME
  159. #define _php_strftime php_strftime
  160. PHPAPI void php_strftime(INTERNAL_FUNCTION_PARAMETERS, int gm);
  161. #endif
  162. PHPAPI char *php_format_date(char *format, int format_len, time_t ts, int localtime TSRMLS_DC);
  163. /* Mechanism to set new TZ database */
  164. PHPAPI void php_date_set_tzdb(timelib_tzdb *tzdb);
  165. PHPAPI timelib_tzinfo *get_timezone_info(TSRMLS_D);
  166. /* Grabbing CE's so that other exts can use the date objects too */
  167. PHPAPI zend_class_entry *php_date_get_date_ce(void);
  168. PHPAPI zend_class_entry *php_date_get_timezone_ce(void);
  169. /* Functions for creating DateTime objects, and initializing them from a string */
  170. PHPAPI zval *php_date_instantiate(zend_class_entry *pce, zval *object TSRMLS_DC);
  171. 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);
  172. #endif /* PHP_DATE_H */