2015-01-03 09:22:58 +00:00
|
|
|
/*
|
2005-06-14 21:32:29 +00:00
|
|
|
+----------------------------------------------------------------------+
|
2019-01-30 09:03:12 +00:00
|
|
|
| Copyright (c) The PHP Group |
|
2005-06-14 21:32:29 +00:00
|
|
|
+----------------------------------------------------------------------+
|
2006-01-01 12:51:34 +00:00
|
|
|
| This source file is subject to version 3.01 of the PHP license, |
|
2005-06-14 21:32:29 +00:00
|
|
|
| that is bundled with this package in the file LICENSE, and is |
|
|
|
|
| available through the world-wide-web at the following url: |
|
2006-01-01 12:51:34 +00:00
|
|
|
| http://www.php.net/license/3_01.txt |
|
2005-06-14 21:32:29 +00:00
|
|
|
| If you did not receive a copy of the PHP license and are unable to |
|
|
|
|
| obtain it through the world-wide-web, please send a note to |
|
|
|
|
| license@php.net so we can mail you a copy immediately. |
|
|
|
|
+----------------------------------------------------------------------+
|
2005-06-17 14:54:00 +00:00
|
|
|
| Authors: Derick Rethans <derick@derickrethans.nl> |
|
2005-06-14 21:32:29 +00:00
|
|
|
+----------------------------------------------------------------------+
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef PHP_DATE_H
|
|
|
|
#define PHP_DATE_H
|
|
|
|
|
2005-10-03 11:17:28 +00:00
|
|
|
#include "lib/timelib.h"
|
2005-10-05 08:20:44 +00:00
|
|
|
#include "Zend/zend_hash.h"
|
2005-10-03 11:17:28 +00:00
|
|
|
|
2015-03-23 19:13:59 +00:00
|
|
|
#include "php_version.h"
|
|
|
|
#define PHP_DATE_VERSION PHP_VERSION
|
|
|
|
|
2005-06-14 21:32:29 +00:00
|
|
|
extern zend_module_entry date_module_entry;
|
|
|
|
#define phpext_date_ptr &date_module_entry
|
|
|
|
|
2005-07-02 21:19:25 +00:00
|
|
|
PHP_RINIT_FUNCTION(date);
|
|
|
|
PHP_RSHUTDOWN_FUNCTION(date);
|
2005-06-14 21:32:29 +00:00
|
|
|
PHP_MINIT_FUNCTION(date);
|
|
|
|
PHP_MSHUTDOWN_FUNCTION(date);
|
|
|
|
PHP_MINFO_FUNCTION(date);
|
|
|
|
|
2008-11-06 09:45:58 +00:00
|
|
|
typedef struct _php_date_obj php_date_obj;
|
|
|
|
typedef struct _php_timezone_obj php_timezone_obj;
|
|
|
|
typedef struct _php_interval_obj php_interval_obj;
|
|
|
|
typedef struct _php_period_obj php_period_obj;
|
|
|
|
|
|
|
|
struct _php_date_obj {
|
|
|
|
timelib_time *time;
|
2014-03-16 09:14:31 +00:00
|
|
|
zend_object std;
|
2008-11-06 09:45:58 +00:00
|
|
|
};
|
|
|
|
|
2014-03-16 09:14:31 +00:00
|
|
|
static inline php_date_obj *php_date_obj_from_obj(zend_object *obj) {
|
|
|
|
return (php_date_obj*)((char*)(obj) - XtOffsetOf(php_date_obj, std));
|
|
|
|
}
|
|
|
|
|
|
|
|
#define Z_PHPDATE_P(zv) php_date_obj_from_obj(Z_OBJ_P((zv)))
|
|
|
|
|
2008-11-06 09:45:58 +00:00
|
|
|
struct _php_timezone_obj {
|
|
|
|
int initialized;
|
|
|
|
int type;
|
|
|
|
union {
|
2014-01-26 12:58:13 +00:00
|
|
|
timelib_tzinfo *tz; /* TIMELIB_ZONETYPE_ID */
|
|
|
|
timelib_sll utc_offset; /* TIMELIB_ZONETYPE_OFFSET */
|
|
|
|
timelib_abbr_info z; /* TIMELIB_ZONETYPE_ABBR */
|
2008-11-06 09:45:58 +00:00
|
|
|
} tzi;
|
2014-03-16 09:14:31 +00:00
|
|
|
zend_object std;
|
2008-11-06 09:45:58 +00:00
|
|
|
};
|
|
|
|
|
2014-03-16 09:14:31 +00:00
|
|
|
static inline php_timezone_obj *php_timezone_obj_from_obj(zend_object *obj) {
|
|
|
|
return (php_timezone_obj*)((char*)(obj) - XtOffsetOf(php_timezone_obj, std));
|
|
|
|
}
|
|
|
|
|
|
|
|
#define Z_PHPTIMEZONE_P(zv) php_timezone_obj_from_obj(Z_OBJ_P((zv)))
|
|
|
|
|
2021-03-30 15:18:57 +00:00
|
|
|
#define PHP_DATE_CIVIL 1
|
|
|
|
#define PHP_DATE_WALL 2
|
|
|
|
|
2008-11-06 09:45:58 +00:00
|
|
|
struct _php_interval_obj {
|
|
|
|
timelib_rel_time *diff;
|
2021-03-30 15:18:57 +00:00
|
|
|
int civil_or_wall;
|
2008-11-06 09:45:58 +00:00
|
|
|
int initialized;
|
2014-03-16 09:14:31 +00:00
|
|
|
zend_object std;
|
2008-11-06 09:45:58 +00:00
|
|
|
};
|
|
|
|
|
2014-03-16 09:14:31 +00:00
|
|
|
static inline php_interval_obj *php_interval_obj_from_obj(zend_object *obj) {
|
|
|
|
return (php_interval_obj*)((char*)(obj) - XtOffsetOf(php_interval_obj, std));
|
|
|
|
}
|
|
|
|
|
|
|
|
#define Z_PHPINTERVAL_P(zv) php_interval_obj_from_obj(Z_OBJ_P((zv)))
|
|
|
|
|
2008-11-06 09:45:58 +00:00
|
|
|
struct _php_period_obj {
|
|
|
|
timelib_time *start;
|
2012-12-20 13:22:18 +00:00
|
|
|
zend_class_entry *start_ce;
|
2010-08-30 15:32:09 +00:00
|
|
|
timelib_time *current;
|
2008-11-06 09:45:58 +00:00
|
|
|
timelib_time *end;
|
|
|
|
timelib_rel_time *interval;
|
|
|
|
int recurrences;
|
|
|
|
int initialized;
|
|
|
|
int include_start_date;
|
2014-03-16 09:14:31 +00:00
|
|
|
zend_object std;
|
2008-11-06 09:45:58 +00:00
|
|
|
};
|
|
|
|
|
2014-03-16 09:14:31 +00:00
|
|
|
static inline php_period_obj *php_period_obj_from_obj(zend_object *obj) {
|
|
|
|
return (php_period_obj*)((char*)(obj) - XtOffsetOf(php_period_obj, std));
|
|
|
|
}
|
|
|
|
|
|
|
|
#define Z_PHPPERIOD_P(zv) php_period_obj_from_obj(Z_OBJ_P((zv)))
|
|
|
|
|
2005-06-18 20:23:19 +00:00
|
|
|
ZEND_BEGIN_MODULE_GLOBALS(date)
|
2013-01-06 01:10:16 +00:00
|
|
|
char *default_timezone;
|
|
|
|
char *timezone;
|
|
|
|
HashTable *tzcache;
|
2008-01-13 15:16:02 +00:00
|
|
|
timelib_error_container *last_errors;
|
2013-01-06 01:10:16 +00:00
|
|
|
int timezone_valid;
|
2005-06-18 20:23:19 +00:00
|
|
|
ZEND_END_MODULE_GLOBALS(date)
|
|
|
|
|
2015-07-29 08:35:57 +00:00
|
|
|
#define DATEG(v) ZEND_MODULE_GLOBALS_ACCESSOR(date, v)
|
2005-06-14 21:32:29 +00:00
|
|
|
|
2020-06-06 12:13:38 +00:00
|
|
|
PHPAPI time_t php_time(void);
|
2019-06-19 07:00:00 +00:00
|
|
|
|
2013-07-23 23:55:43 +00:00
|
|
|
/* Backwards compatibility wrapper */
|
2020-06-07 09:01:19 +00:00
|
|
|
PHPAPI zend_long php_parse_date(const char *string, zend_long *now);
|
2005-07-04 13:21:39 +00:00
|
|
|
PHPAPI void php_mktime(INTERNAL_FUNCTION_PARAMETERS, int gmt);
|
2014-12-13 22:06:14 +00:00
|
|
|
PHPAPI int php_idate(char format, time_t ts, int localtime);
|
2019-03-13 22:14:37 +00:00
|
|
|
|
2005-07-03 19:14:55 +00:00
|
|
|
#define _php_strftime php_strftime
|
2019-03-13 22:14:37 +00:00
|
|
|
|
2005-07-03 19:14:55 +00:00
|
|
|
PHPAPI void php_strftime(INTERNAL_FUNCTION_PARAMETERS, int gm);
|
2020-06-07 09:01:19 +00:00
|
|
|
PHPAPI zend_string *php_format_date(const char *format, size_t format_len, time_t ts, int localtime);
|
2005-06-19 22:15:27 +00:00
|
|
|
|
2005-10-03 11:17:28 +00:00
|
|
|
/* Mechanism to set new TZ database */
|
|
|
|
PHPAPI void php_date_set_tzdb(timelib_tzdb *tzdb);
|
2014-12-13 22:06:14 +00:00
|
|
|
PHPAPI timelib_tzinfo *get_timezone_info(void);
|
2005-10-03 11:17:28 +00:00
|
|
|
|
2008-11-06 09:45:58 +00:00
|
|
|
/* Grabbing CE's so that other exts can use the date objects too */
|
|
|
|
PHPAPI zend_class_entry *php_date_get_date_ce(void);
|
2015-03-31 10:08:56 +00:00
|
|
|
PHPAPI zend_class_entry *php_date_get_immutable_ce(void);
|
2016-06-28 18:30:58 +00:00
|
|
|
PHPAPI zend_class_entry *php_date_get_interface_ce(void);
|
2008-11-06 09:45:58 +00:00
|
|
|
PHPAPI zend_class_entry *php_date_get_timezone_ce(void);
|
2018-05-11 14:57:39 +00:00
|
|
|
PHPAPI zend_class_entry *php_date_get_interval_ce(void);
|
|
|
|
PHPAPI zend_class_entry *php_date_get_period_ce(void);
|
2008-11-06 09:45:58 +00:00
|
|
|
|
2010-04-10 20:33:41 +00:00
|
|
|
/* Functions for creating DateTime objects, and initializing them from a string */
|
2020-09-04 14:55:08 +00:00
|
|
|
#define PHP_DATE_INIT_CTOR 0x01
|
|
|
|
#define PHP_DATE_INIT_FORMAT 0x02
|
|
|
|
|
2014-12-13 22:06:14 +00:00
|
|
|
PHPAPI zval *php_date_instantiate(zend_class_entry *pce, zval *object);
|
2020-09-04 14:55:08 +00:00
|
|
|
PHPAPI int php_date_initialize(php_date_obj *dateobj, const char *time_str, size_t time_str_len, const char *format, zval *timezone_object, int flags);
|
2010-04-10 20:33:41 +00:00
|
|
|
|
|
|
|
|
2005-06-14 21:32:29 +00:00
|
|
|
#endif /* PHP_DATE_H */
|