#include "lib/timelib.h"
#include <time.h>
+/* {{{ Function table */
function_entry date_functions[] = {
PHP_FE(strtotime, NULL)
PHP_FE(date, NULL)
PHP_FE(localtime, NULL)
PHP_FE(getdate, NULL)
- PHP_FE(date_timezone_set, NULL)
- PHP_FE(date_timezone_get, NULL)
+ PHP_FE(date_default_timezone_set, NULL)
+ PHP_FE(date_default_timezone_get, NULL)
{NULL, NULL, NULL}
};
+/* }}} */
ZEND_DECLARE_MODULE_GLOBALS(date)
+/* {{{ INI Settings */
PHP_INI_BEGIN()
STD_PHP_INI_ENTRY("date.timezone", "", PHP_INI_ALL, OnUpdateString, default_timezone, zend_date_globals, date_globals)
PHP_INI_END()
+/* }}} */
-
+/* {{{ Module struct */
zend_module_entry date_module_entry = {
STANDARD_MODULE_HEADER,
"date", /* extension name */
PHP_VERSION, /* extension version */
STANDARD_MODULE_PROPERTIES
};
+/* }}} */
+
/* {{{ php_date_init_globals */
static void php_date_init_globals(zend_date_globals *date_globals)
}
/* }}} */
+/* {{{ PHP_RINIT_FUNCTION */
PHP_RINIT_FUNCTION(date)
{
if (DATEG(timezone)) {
return SUCCESS;
}
+/* }}} */
+/* {{{ PHP_RSHUTDOWN_FUNCTION */
PHP_RSHUTDOWN_FUNCTION(date)
{
if (DATEG(timezone)) {
return SUCCESS;
}
+/* }}} */
+/* {{{ PHP_MINIT_FUNCTION */
PHP_MINIT_FUNCTION(date)
{
ZEND_INIT_MODULE_GLOBALS(date, php_date_init_globals, NULL);
return SUCCESS;
}
+/* }}} */
-
+/* {{{ PHP_MSHUTDOWN_FUNCTION */
PHP_MSHUTDOWN_FUNCTION(date)
{
UNREGISTER_INI_ENTRIES();
return SUCCESS;
}
+/* }}} */
-
+/* {{{ PHP_MINFO_FUNCTION */
PHP_MINFO_FUNCTION(date)
{
php_info_print_table_start();
php_info_print_table_row(2, "date/time support", "enabled");
php_info_print_table_end();
}
+/* }}} */
-/* =[ Helper functions ] ================================================== */
+/* {{{ Helper functions */
static char* guess_timezone(TSRMLS_D)
{
char *env;
}
return tzi;
}
+/* }}} */
+
-/* =[ date() and gmdate() ]================================================ */
+/* {{{ date() and gmdate() data */
#include "ext/standard/php_smart_str.h"
static char *mon_full_names[] = {
}
return "th";
}
+/* }}} */
+/* {{{ php_format_date - (gm)date helper */
static char *php_format_date(char *format, int format_len, timelib_time *t, int localtime)
{
smart_str string = {0};
RETVAL_STRING(string, 0);
timelib_time_dtor(t);
}
+/* }}} */
+/* {{{ proto string date(string format [, long timestamp])
+ Format a local date/time */
PHP_FUNCTION(date)
{
php_date(INTERNAL_FUNCTION_PARAM_PASSTHRU, 1);
}
+/* }}} */
+/* {{{ proto string gmdate(string format [, long timestamp])
+ Format a GMT date/time */
PHP_FUNCTION(gmdate)
{
php_date(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0);
}
+/* }}} */
-/* Backwards compability function */
+
+/* {{{ php_parse_date: Backwards compability function */
signed long php_parse_date(char *string, signed long *now)
{
timelib_time *parsed_time;
}
return retval;
}
+/* }}} */
/* {{{ proto int strtotime(string time, int now)
}
/* }}} */
+
+/* {{{ php_mktime - (gm)mktime helper */
PHPAPI void php_mktime(INTERNAL_FUNCTION_PARAMETERS, int gmt)
{
long hou, min, sec, mon, day, yea, dst = -1;
RETURN_LONG(ts);
}
}
+/* }}} */
/* {{{ proto int mktime(int hour, int min, int sec, int mon, int day, int year)
Get UNIX timestamp for a date */
}
/* }}} */
+
/* {{{ proto bool checkdate(int month, int day, int year)
Returns true(1) if it is a valid date in gregorian calendar */
PHP_FUNCTION(checkdate)
/* }}} */
#ifdef HAVE_STRFTIME
-/* {{{ php_strftime
- */
+/* {{{ php_strftime - (gm)strftime helper */
PHPAPI void php_strftime(INTERNAL_FUNCTION_PARAMETERS, int gmt)
{
char *format, *buf;
Format a local time/date according to locale settings */
PHP_FUNCTION(strftime)
{
- _php_strftime(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0);
+ php_strftime(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0);
}
/* }}} */
Format a GMT/UCT time/date according to locale settings */
PHP_FUNCTION(gmstrftime)
{
- _php_strftime(INTERNAL_FUNCTION_PARAM_PASSTHRU, 1);
+ php_strftime(INTERNAL_FUNCTION_PARAM_PASSTHRU, 1);
}
/* }}} */
#endif
}
/* }}} */
-PHP_FUNCTION(date_timezone_set)
+
+/* {{{ proto void date_default_timezone_set(string timezone_identifier)
+ Sets the default timezone used by all date/time functions in a script */
+PHP_FUNCTION(date_default_timezone_set)
{
char *zone;
int zone_len;
DATEG(timezone) = estrndup(zone, zone_len);
RETURN_TRUE;
}
+/* }}} */
-PHP_FUNCTION(date_timezone_get)
+/* {{{ proto void date_default_timezone_get(string timezone_identifier)
+ Gets the default timezone used by all date/time functions in a script */
+PHP_FUNCTION(date_default_timezone_get)
{
RETURN_STRING(DATEG(timezone), 0);
}
+/* }}} */
/*
* Local variables: