Back to index

php5  5.3.10
php_date.h
Go to the documentation of this file.
00001 /* 
00002    +----------------------------------------------------------------------+
00003    | PHP Version 5                                                        |
00004    +----------------------------------------------------------------------+
00005    | Copyright (c) 1997-2012 The PHP Group                                |
00006    +----------------------------------------------------------------------+
00007    | This source file is subject to version 3.01 of the PHP license,      |
00008    | that is bundled with this package in the file LICENSE, and is        |
00009    | available through the world-wide-web at the following url:           |
00010    | http://www.php.net/license/3_01.txt                                  |
00011    | If you did not receive a copy of the PHP license and are unable to   |
00012    | obtain it through the world-wide-web, please send a note to          |
00013    | license@php.net so we can mail you a copy immediately.               |
00014    +----------------------------------------------------------------------+
00015    | Authors: Derick Rethans <derick@derickrethans.nl>                    |
00016    +----------------------------------------------------------------------+
00017 */
00018 
00019 /* $Id: php_date.h 321634 2012-01-01 13:15:04Z felipe $ */
00020 
00021 #ifndef PHP_DATE_H
00022 #define PHP_DATE_H
00023 
00024 #include "lib/timelib.h"
00025 #include "Zend/zend_hash.h"
00026 
00027 extern zend_module_entry date_module_entry;
00028 #define phpext_date_ptr &date_module_entry
00029 
00030 PHP_FUNCTION(date);
00031 PHP_FUNCTION(idate);
00032 PHP_FUNCTION(gmdate);
00033 PHP_FUNCTION(strtotime);
00034 
00035 PHP_FUNCTION(mktime);
00036 PHP_FUNCTION(gmmktime);
00037 
00038 PHP_FUNCTION(checkdate);
00039 
00040 #ifdef HAVE_STRFTIME
00041 PHP_FUNCTION(strftime);
00042 PHP_FUNCTION(gmstrftime);
00043 #endif
00044 
00045 PHP_FUNCTION(time);
00046 PHP_FUNCTION(localtime);
00047 PHP_FUNCTION(getdate);
00048 
00049 /* Advanced Interface */
00050 PHP_METHOD(DateTime, __construct);
00051 PHP_METHOD(DateTime, __wakeup);
00052 PHP_METHOD(DateTime, __set_state);
00053 PHP_FUNCTION(date_create);
00054 PHP_FUNCTION(date_create_from_format);
00055 PHP_FUNCTION(date_parse);
00056 PHP_FUNCTION(date_parse_from_format);
00057 PHP_FUNCTION(date_get_last_errors);
00058 PHP_FUNCTION(date_format);
00059 PHP_FUNCTION(date_modify);
00060 PHP_FUNCTION(date_add);
00061 PHP_FUNCTION(date_sub);
00062 PHP_FUNCTION(date_timezone_get);
00063 PHP_FUNCTION(date_timezone_set);
00064 PHP_FUNCTION(date_offset_get);
00065 PHP_FUNCTION(date_diff);
00066 
00067 PHP_FUNCTION(date_time_set);
00068 PHP_FUNCTION(date_date_set);
00069 PHP_FUNCTION(date_isodate_set);
00070 PHP_FUNCTION(date_timestamp_set);
00071 PHP_FUNCTION(date_timestamp_get);
00072 
00073 PHP_METHOD(DateTimeZone, __construct);
00074 PHP_FUNCTION(timezone_open);
00075 PHP_FUNCTION(timezone_name_get);
00076 PHP_FUNCTION(timezone_name_from_abbr);
00077 PHP_FUNCTION(timezone_offset_get);
00078 PHP_FUNCTION(timezone_transitions_get);
00079 PHP_FUNCTION(timezone_location_get);
00080 PHP_FUNCTION(timezone_identifiers_list);
00081 PHP_FUNCTION(timezone_abbreviations_list);
00082 PHP_FUNCTION(timezone_version_get);
00083 
00084 PHP_METHOD(DateInterval, __construct);
00085 PHP_METHOD(DateInterval, __wakeup);
00086 PHP_METHOD(DateInterval, __set_state);
00087 PHP_FUNCTION(date_interval_format);
00088 PHP_FUNCTION(date_interval_create_from_date_string);
00089 
00090 PHP_METHOD(DatePeriod, __construct);
00091 
00092 /* Options and Configuration */
00093 PHP_FUNCTION(date_default_timezone_set);
00094 PHP_FUNCTION(date_default_timezone_get);
00095 
00096 /* Astro functions */
00097 PHP_FUNCTION(date_sunrise);
00098 PHP_FUNCTION(date_sunset);
00099 PHP_FUNCTION(date_sun_info);
00100 
00101 PHP_RINIT_FUNCTION(date);
00102 PHP_RSHUTDOWN_FUNCTION(date);
00103 PHP_MINIT_FUNCTION(date);
00104 PHP_MSHUTDOWN_FUNCTION(date);
00105 PHP_MINFO_FUNCTION(date);
00106 
00107 typedef struct _php_date_obj php_date_obj;
00108 typedef struct _php_timezone_obj php_timezone_obj;
00109 typedef struct _php_interval_obj php_interval_obj;
00110 typedef struct _php_period_obj php_period_obj;
00111 
00112 struct _php_date_obj {
00113        zend_object   std;
00114        timelib_time *time;
00115        HashTable    *props;
00116 };
00117 
00118 struct _php_timezone_obj {
00119        zend_object     std;
00120        int             initialized;
00121        int             type;
00122        union {
00123               timelib_tzinfo *tz; /* TIMELIB_ZONETYPE_ID; */
00124               timelib_sll     utc_offset; /* TIMELIB_ZONETYPE_OFFSET */
00125               struct                      /* TIMELIB_ZONETYPE_ABBR */
00126               {
00127                      timelib_sll  utc_offset;
00128                      char        *abbr;
00129                      int          dst;
00130               } z;
00131        } tzi;
00132 };
00133 
00134 struct _php_interval_obj {
00135        zend_object       std;
00136        timelib_rel_time *diff;
00137        HashTable        *props;
00138        int               initialized;
00139 };
00140 
00141 struct _php_period_obj {
00142        zend_object       std;
00143        timelib_time     *start;
00144        timelib_time     *current;
00145        timelib_time     *end;
00146        timelib_rel_time *interval;
00147        int               recurrences;
00148        int               initialized;
00149        int               include_start_date;
00150 };
00151 
00152 ZEND_BEGIN_MODULE_GLOBALS(date)
00153        char      *default_timezone;
00154        char      *timezone;
00155        HashTable *tzcache;
00156        timelib_error_container *last_errors;
00157 ZEND_END_MODULE_GLOBALS(date)
00158 
00159 #ifdef ZTS
00160 #define DATEG(v) TSRMG(date_globals_id, zend_date_globals *, v)
00161 #else
00162 #define DATEG(v) (date_globals.v)
00163 #endif
00164 
00165 /* Backwards compability wrapper */
00166 PHPAPI signed long php_parse_date(char *string, signed long *now);
00167 PHPAPI void php_mktime(INTERNAL_FUNCTION_PARAMETERS, int gmt);
00168 PHPAPI int php_idate(char format, time_t ts, int localtime);
00169 #if HAVE_STRFTIME
00170 #define _php_strftime php_strftime
00171 PHPAPI void php_strftime(INTERNAL_FUNCTION_PARAMETERS, int gm);
00172 #endif
00173 PHPAPI char *php_format_date(char *format, int format_len, time_t ts, int localtime TSRMLS_DC);
00174 
00175 /* Mechanism to set new TZ database */
00176 PHPAPI void php_date_set_tzdb(timelib_tzdb *tzdb);
00177 PHPAPI timelib_tzinfo *get_timezone_info(TSRMLS_D);
00178 
00179 /* Grabbing CE's so that other exts can use the date objects too */
00180 PHPAPI zend_class_entry *php_date_get_date_ce(void);
00181 PHPAPI zend_class_entry *php_date_get_timezone_ce(void);
00182 
00183 /* Functions for creating DateTime objects, and initializing them from a string */
00184 PHPAPI zval *php_date_instantiate(zend_class_entry *pce, zval *object TSRMLS_DC);
00185 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);
00186 
00187 
00188 #endif /* PHP_DATE_H */