php-internal-docs 8.4.8
Unofficial docs for php/php-src
Loading...
Searching...
No Matches
php_date.h
Go to the documentation of this file.
1/*
2 +----------------------------------------------------------------------+
3 | Copyright (c) The PHP Group |
4 +----------------------------------------------------------------------+
5 | This source file is subject to version 3.01 of the PHP license, |
6 | that is bundled with this package in the file LICENSE, and is |
7 | available through the world-wide-web at the following url: |
8 | https://www.php.net/license/3_01.txt |
9 | If you did not receive a copy of the PHP license and are unable to |
10 | obtain it through the world-wide-web, please send a note to |
11 | license@php.net so we can mail you a copy immediately. |
12 +----------------------------------------------------------------------+
13 | Authors: Derick Rethans <derick@derickrethans.nl> |
14 +----------------------------------------------------------------------+
15*/
16
17#ifndef PHP_DATE_H
18#define PHP_DATE_H
19
20#include "lib/timelib.h"
21#include "Zend/zend_hash.h"
22
23/* Same as SIZEOF_ZEND_LONG but using TIMELIB_LONG_MAX/MIN */
24#if TIMELIB_LONG_MAX == INT32_MAX
25# define PHP_DATE_SIZEOF_LONG 4
26#elif TIMELIB_LONG_MAX == INT64_MAX
27# define PHP_DATE_SIZEOF_LONG 8
28#else
29# error "Unknown TIMELIB LONG SIZE"
30#endif
31
32/* Same as ZEND_DOUBLE_FITS_LONG but using TIMELIB_LONG_MAX/MIN */
33#if PHP_DATE_SIZEOF_LONG == 4
34# define PHP_DATE_DOUBLE_FITS_LONG(d) (!((d) > (double)TIMELIB_LONG_MAX || (d) < (double)TIMELIB_LONG_MIN))
35#elif PHP_DATE_SIZEOF_LONG == 8
36 /* >= as (double)TIMELIB_LONG_MAX is outside signed range */
37# define PHP_DATE_DOUBLE_FITS_LONG(d) (!((d) >= (double)TIMELIB_LONG_MAX || (d) < (double)TIMELIB_LONG_MIN))
38#endif
39
40#include "php_version.h"
41#define PHP_DATE_VERSION PHP_VERSION
42
44#define phpext_date_ptr &date_module_entry
45
52
57
62
63static inline php_date_obj *php_date_obj_from_obj(zend_object *obj) {
64 return (php_date_obj*)((char*)(obj) - XtOffsetOf(php_date_obj, std));
65}
66
67#define Z_PHPDATE_P(zv) php_date_obj_from_obj(Z_OBJ_P((zv)))
68
71 int type;
72 union {
73 timelib_tzinfo *tz; /* TIMELIB_ZONETYPE_ID */
74 timelib_sll utc_offset; /* TIMELIB_ZONETYPE_OFFSET */
75 timelib_abbr_info z; /* TIMELIB_ZONETYPE_ABBR */
76 } tzi;
78};
79
80static inline php_timezone_obj *php_timezone_obj_from_obj(zend_object *obj) {
81 return (php_timezone_obj*)((char*)(obj) - XtOffsetOf(php_timezone_obj, std));
82}
83
84#define Z_PHPTIMEZONE_P(zv) php_timezone_obj_from_obj(Z_OBJ_P((zv)))
85
86#define PHP_DATE_CIVIL 1
87#define PHP_DATE_WALL 2
88
97
98static inline php_interval_obj *php_interval_obj_from_obj(zend_object *obj) {
99 return (php_interval_obj*)((char*)(obj) - XtOffsetOf(php_interval_obj, std));
100}
101
102#define Z_PHPINTERVAL_P(zv) php_interval_obj_from_obj(Z_OBJ_P((zv)))
103
116
117static inline php_period_obj *php_period_obj_from_obj(zend_object *obj) {
118 return (php_period_obj*)((char*)(obj) - XtOffsetOf(php_period_obj, std));
119}
120
121#define Z_PHPPERIOD_P(zv) php_period_obj_from_obj(Z_OBJ_P((zv)))
122
125 char *timezone;
129
130#define DATEG(v) ZEND_MODULE_GLOBALS_ACCESSOR(date, v)
131
132PHPAPI time_t php_time(void);
133
134/* Backwards compatibility wrapper */
135PHPAPI zend_long php_parse_date(const char *string, zend_long *now);
137PHPAPI int php_idate(char format, time_t ts, bool localtime);
138
139#define _php_strftime php_strftime
140
142PHPAPI zend_string *php_format_date(const char *format, size_t format_len, time_t ts, bool localtime);
143PHPAPI zend_string *php_format_date_obj(const char *format, size_t format_len, php_date_obj *date_obj);
144
145/* Mechanism to set new TZ database */
148
149/* Grabbing CE's so that other exts can use the date objects too */
156
157/* Functions for creating DateTime objects, and initializing them from a string */
158#define PHP_DATE_INIT_CTOR 0x01
159#define PHP_DATE_INIT_FORMAT 0x02
160
162PHPAPI bool php_date_initialize(php_date_obj *dateobj, const char *time_str, size_t time_str_len, const char *format, zval *timezone_object, int flags);
165
166#endif /* PHP_DATE_H */
#define PHP_MSHUTDOWN_FUNCTION
Definition php.h:401
#define PHP_MINIT_FUNCTION
Definition php.h:400
#define PHP_MINFO_FUNCTION
Definition php.h:404
#define PHP_RINIT_FUNCTION
Definition php.h:402
#define PHP_RSHUTDOWN_FUNCTION
Definition php.h:403
#define PHPAPI
Definition php.h:71
zend_module_entry date_module_entry
Definition php_date.c:370
php_date_obj * dateobj
Definition php_date.c:3976
PHPAPI zend_long php_parse_date(const char *string, zend_long *now)
Definition php_date.c:1057
PHPAPI zend_class_entry * php_date_get_immutable_ce(void)
Definition php_date.c:279
struct _php_timezone_obj php_timezone_obj
Definition php_date.h:54
PHPAPI zend_class_entry * php_date_get_date_ce(void)
Definition php_date.c:274
PHPAPI zend_class_entry * php_date_get_period_ce(void)
Definition php_date.c:299
PHPAPI zend_class_entry * php_date_get_interface_ce(void)
Definition php_date.c:284
struct _php_interval_obj php_interval_obj
Definition php_date.h:55
PHPAPI int php_idate(char format, time_t ts, bool localtime)
Definition php_date.c:901
PHPAPI zend_string * php_format_date_obj(const char *format, size_t format_len, php_date_obj *date_obj)
Definition php_date.c:846
struct _php_date_obj php_date_obj
Definition php_date.h:53
PHPAPI timelib_tzinfo * get_timezone_info(void)
Definition php_date.c:573
HashTable * tzcache
Definition php_date.h:126
PHPAPI bool php_date_initialize_from_ts_double(php_date_obj *dateobj, double ts)
Definition php_date.c:2529
PHPAPI zend_string * php_format_date(const char *format, size_t format_len, time_t ts, bool localtime)
Definition php_date.c:875
PHPAPI zend_class_entry * php_date_get_timezone_ce(void)
Definition php_date.c:289
PHPAPI void php_date_set_tzdb(timelib_tzdb *tzdb)
Definition php_date.c:1045
PHPAPI time_t php_time(void)
Definition php_date.c:56
PHPAPI void php_strftime(INTERNAL_FUNCTION_PARAMETERS, bool gm)
Definition php_date.c:1257
PHPAPI bool php_date_initialize(php_date_obj *dateobj, const char *time_str, size_t time_str_len, const char *format, zval *timezone_object, int flags)
Definition php_date.c:2403
PHPAPI void php_mktime(INTERNAL_FUNCTION_PARAMETERS, bool gmt)
Definition php_date.c:1141
timelib_error_container * last_errors
Definition php_date.h:127
struct _php_period_obj php_period_obj
Definition php_date.h:56
PHPAPI zval * php_date_instantiate(zend_class_entry *pce, zval *object)
Definition php_date.c:2356
char * default_timezone
Definition php_date.h:124
PHPAPI zend_class_entry * php_date_get_interval_ce(void)
Definition php_date.c:294
PHPAPI void php_date_initialize_from_ts_long(php_date_obj *dateobj, zend_long sec, int usec)
Definition php_date.c:2519
date(string $format, ?int $timestamp=null)
localtime(?int $timestamp=null, bool $associative=false)
time_t now
Definition session.c:1281
zend_object std
Definition php_date.h:60
timelib_time * time
Definition php_date.h:59
zend_object std
Definition php_date.h:95
timelib_rel_time * diff
Definition php_date.h:90
zend_string * date_string
Definition php_date.h:93
timelib_rel_time * interval
Definition php_date.h:109
zend_object std
Definition php_date.h:114
bool include_end_date
Definition php_date.h:113
bool include_start_date
Definition php_date.h:112
timelib_time * start
Definition php_date.h:105
timelib_time * end
Definition php_date.h:108
timelib_time * current
Definition php_date.h:107
zend_class_entry * start_ce
Definition php_date.h:106
timelib_tzinfo * tz
Definition php_date.h:73
timelib_sll utc_offset
Definition php_date.h:74
union _php_timezone_obj::@213245010343033015320150043202117071337023242314 tzi
timelib_abbr_info z
Definition php_date.h:75
zend_object std
Definition php_date.h:77
struct _timelib_error_container timelib_error_container
struct _timelib_tzdb timelib_tzdb
struct _timelib_time timelib_time
struct _timelib_rel_time timelib_rel_time
signed long long timelib_sll
Definition timelib.h:136
struct _timelib_tzinfo timelib_tzinfo
struct _timelib_abbr_info timelib_abbr_info
#define INTERNAL_FUNCTION_PARAMETERS
Definition zend.h:49
#define ZEND_END_MODULE_GLOBALS(module_name)
Definition zend_API.h:248
#define ZEND_MODULE_POST_ZEND_DEACTIVATE_D(module)
Definition zend_API.h:236
#define ZEND_BEGIN_MODULE_GLOBALS(module_name)
Definition zend_API.h:246
struct _zval_struct zval
int32_t zend_long
Definition zend_long.h:42
struct _zend_string zend_string
struct _zend_module_entry zend_module_entry
#define XtOffsetOf(s_type, field)
struct _zend_class_entry zend_class_entry
struct _zend_object zend_object
struct _zend_array HashTable
Definition zend_types.h:386