mirror of
https://github.com/php/php-src.git
synced 2025-01-02 08:54:04 +08:00
Merge branch 'master' of git.php.net:php-src
This commit is contained in:
commit
e3e7f47441
76
UPGRADING
76
UPGRADING
@ -49,13 +49,85 @@ PHP X.Y UPGRADE NOTES
|
||||
5. New Functions
|
||||
========================================
|
||||
|
||||
- Intl:
|
||||
- intlcal_create_instance()
|
||||
- intlcal_get_keyword_values_for_locale()
|
||||
- intlcal_get_now()
|
||||
- intlcal_get_available_locales()
|
||||
- intlcal_get()
|
||||
- intlcal_get_time()
|
||||
- intlcal_set_time()
|
||||
- intlcal_add()
|
||||
- intlcal_set_time_zone()
|
||||
- intlcal_after()
|
||||
- intlcal_before()
|
||||
- intlcal_set()
|
||||
- intlcal_roll()
|
||||
- intlcal_clear()
|
||||
- intlcal_field_difference()
|
||||
- intlcal_get_actual_maximum()
|
||||
- intlcal_get_actual_minimum()
|
||||
- intlcal_get_day_of_week_type()
|
||||
- intlcal_get_first_day_of_week()
|
||||
- intlcal_get_greatest_minimum()
|
||||
- intlcal_get_least_maximum()
|
||||
- intlcal_get_locale()
|
||||
- intlcal_get_maximum()
|
||||
- intlcal_get_minimal_days_in_first_week()
|
||||
- intlcal_get_minimum()
|
||||
- intlcal_get_time_zone()
|
||||
- intlcal_get_type()
|
||||
- intlcal_get_weekend_transition()
|
||||
- intlcal_in_daylight_time()
|
||||
- intlcal_is_equivalent_to()
|
||||
- intlcal_is_lenient()
|
||||
- intlcal_is_set()
|
||||
- intlcal_is_weekend()
|
||||
- intlcal_set_first_day_of_week()
|
||||
- intlcal_set_lenient()
|
||||
- intlcal_equals()
|
||||
- intlcal_get_repeated_wall_time_option()
|
||||
- intlcal_get_skipped_wall_time_option()
|
||||
- intlcal_set_repeated_wall_time_option()
|
||||
- intlcal_set_skipped_wall_time_option()
|
||||
- intlcal_get_error_code()
|
||||
- intlcal_get_error_message()
|
||||
- intlgregcal_create_instance()
|
||||
- intlgregcal_set_gregorian_change()
|
||||
- intlgregcal_get_gregorian_change()
|
||||
- intlgregcal_is_leap_year()
|
||||
- intltz_create_time_zone()
|
||||
- intltz_create_default()
|
||||
- intltz_get_id()
|
||||
- intltz_get_gmt()
|
||||
- intltz_get_unknown()
|
||||
- intltz_create_enumeration()
|
||||
- intltz_count_equivalent_ids()
|
||||
- intltz_create_time_zone_id_enumeration()
|
||||
- intltz_get_canonical_id()
|
||||
- intltz_get_region()
|
||||
- intltz_get_tz_data_version()
|
||||
- intltz_get_equivalent_id()
|
||||
- intltz_use_daylight_time()
|
||||
- intltz_get_offset()
|
||||
- intltz_get_raw_offset()
|
||||
- intltz_has_same_rules()
|
||||
- intltz_get_display_name()
|
||||
- intltz_get_dst_savings()
|
||||
- intltz_get_error_code()
|
||||
- intltz_get_error_message()
|
||||
|
||||
- SPL:
|
||||
- SplFixedArray::__wakeup()
|
||||
|
||||
========================================
|
||||
6. New Classes and Interfaces
|
||||
========================================
|
||||
|
||||
- SPL:
|
||||
- SplFixedArray::__wakeup()
|
||||
- Intl:
|
||||
- IntlCalendar
|
||||
- IntlGregorianCalendar
|
||||
- IntlTimeZone
|
||||
|
||||
========================================
|
||||
7. Removed Extensions
|
||||
|
534
ext/intl/calendar/calendar_class.cpp
Normal file
534
ext/intl/calendar/calendar_class.cpp
Normal file
@ -0,0 +1,534 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| PHP Version 5 |
|
||||
+----------------------------------------------------------------------+
|
||||
| This source file is subject to version 3.01 of the PHP license, |
|
||||
| that is bundled with this package in the file LICENSE, and is |
|
||||
| available through the world-wide-web at the following url: |
|
||||
| http://www.php.net/license/3_01.txt |
|
||||
| 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. |
|
||||
+----------------------------------------------------------------------+
|
||||
| Authors: Gustavo Lopes <cataphract@php.net> |
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <unicode/calendar.h>
|
||||
#include <unicode/gregocal.h>
|
||||
|
||||
extern "C" {
|
||||
#define USE_TIMEZONE_POINTER 1
|
||||
#include "../timezone/timezone_class.h"
|
||||
#define USE_CALENDAR_POINTER 1
|
||||
#include "calendar_class.h"
|
||||
#include "calendar_methods.h"
|
||||
#include "gregoriancalendar_methods.h"
|
||||
#include <zend_exceptions.h>
|
||||
#include <assert.h>
|
||||
}
|
||||
|
||||
/* {{{ Global variables */
|
||||
zend_class_entry *Calendar_ce_ptr;
|
||||
zend_class_entry *GregorianCalendar_ce_ptr;
|
||||
zend_object_handlers Calendar_handlers;
|
||||
/* }}} */
|
||||
|
||||
U_CFUNC void calendar_object_create(zval *object,
|
||||
Calendar *calendar TSRMLS_DC)
|
||||
{
|
||||
UClassID classId = calendar->getDynamicClassID();
|
||||
zend_class_entry *ce;
|
||||
|
||||
//if (dynamic_cast<GregorianCalendar*>(calendar) != NULL) {
|
||||
if (classId == GregorianCalendar::getStaticClassID()) {
|
||||
ce = GregorianCalendar_ce_ptr;
|
||||
} else {
|
||||
ce = Calendar_ce_ptr;
|
||||
}
|
||||
|
||||
object_init_ex(object, ce);
|
||||
calendar_object_construct(object, calendar TSRMLS_CC);
|
||||
}
|
||||
|
||||
U_CFUNC void calendar_object_construct(zval *object,
|
||||
Calendar *calendar TSRMLS_DC)
|
||||
{
|
||||
Calendar_object *co;
|
||||
|
||||
CALENDAR_METHOD_FETCH_OBJECT_NO_CHECK; //populate to from object
|
||||
assert(co->ucal == NULL);
|
||||
co->ucal = (Calendar*)calendar;
|
||||
}
|
||||
|
||||
/* {{{ clone handler for Calendar */
|
||||
static zend_object_value Calendar_clone_obj(zval *object TSRMLS_DC)
|
||||
{
|
||||
Calendar_object *co_orig,
|
||||
*co_new;
|
||||
zend_object_value ret_val;
|
||||
intl_error_reset(NULL TSRMLS_CC);
|
||||
|
||||
co_orig = (Calendar_object*)zend_object_store_get_object(object TSRMLS_CC);
|
||||
intl_error_reset(INTL_DATA_ERROR_P(co_orig) TSRMLS_CC);
|
||||
|
||||
ret_val = Calendar_ce_ptr->create_object(Z_OBJCE_P(object) TSRMLS_CC);
|
||||
co_new = (Calendar_object*)zend_object_store_get_object_by_handle(ret_val.handle TSRMLS_CC);
|
||||
|
||||
zend_objects_clone_members(&co_new->zo, ret_val,
|
||||
&co_orig->zo, Z_OBJ_HANDLE_P(object) TSRMLS_CC);
|
||||
|
||||
if (co_orig->ucal != NULL) {
|
||||
Calendar *newCalendar;
|
||||
|
||||
newCalendar = co_orig->ucal->clone();
|
||||
if (!newCalendar) {
|
||||
char *err_msg;
|
||||
intl_errors_set_code(CALENDAR_ERROR_P(co_orig),
|
||||
U_MEMORY_ALLOCATION_ERROR TSRMLS_CC);
|
||||
intl_errors_set_custom_msg(CALENDAR_ERROR_P(co_orig),
|
||||
"Could not clone IntlCalendar", 0 TSRMLS_CC);
|
||||
err_msg = intl_error_get_message(CALENDAR_ERROR_P(co_orig) TSRMLS_CC);
|
||||
zend_throw_exception(NULL, err_msg, 0 TSRMLS_CC);
|
||||
efree(err_msg);
|
||||
} else {
|
||||
co_new->ucal = newCalendar;
|
||||
}
|
||||
} else {
|
||||
zend_throw_exception(NULL, "Cannot clone unconstructed IntlCalendar", 0 TSRMLS_CC);
|
||||
}
|
||||
|
||||
return ret_val;
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
static const struct {
|
||||
UCalendarDateFields field;
|
||||
const char *name;
|
||||
} debug_info_fields[] = {
|
||||
{UCAL_ERA, "era"},
|
||||
{UCAL_YEAR, "year"},
|
||||
{UCAL_MONTH, "month"},
|
||||
{UCAL_WEEK_OF_YEAR, "week of year"},
|
||||
{UCAL_WEEK_OF_MONTH, "week of month"},
|
||||
{UCAL_DAY_OF_YEAR, "day of year"},
|
||||
{UCAL_DAY_OF_MONTH, "day of month"},
|
||||
{UCAL_DAY_OF_WEEK, "day of week"},
|
||||
{UCAL_DAY_OF_WEEK_IN_MONTH, "day of week in month"},
|
||||
{UCAL_AM_PM, "AM/PM"},
|
||||
{UCAL_HOUR, "hour"},
|
||||
{UCAL_HOUR_OF_DAY, "hour of day"},
|
||||
{UCAL_MINUTE, "minute"},
|
||||
{UCAL_SECOND, "second"},
|
||||
{UCAL_MILLISECOND, "millisecond"},
|
||||
{UCAL_ZONE_OFFSET, "zone offset"},
|
||||
{UCAL_DST_OFFSET, "DST offset"},
|
||||
{UCAL_YEAR_WOY, "year for week of year"},
|
||||
{UCAL_DOW_LOCAL, "localized day of week"},
|
||||
{UCAL_EXTENDED_YEAR, "extended year"},
|
||||
{UCAL_JULIAN_DAY, "julian day"},
|
||||
{UCAL_MILLISECONDS_IN_DAY, "milliseconds in day"},
|
||||
{UCAL_IS_LEAP_MONTH, "is leap month"},
|
||||
};
|
||||
|
||||
/* {{{ get_debug_info handler for Calendar */
|
||||
static HashTable *Calendar_get_debug_info(zval *object, int *is_temp TSRMLS_DC)
|
||||
{
|
||||
zval zv = zval_used_for_init,
|
||||
*zfields;
|
||||
Calendar_object *co;
|
||||
const Calendar *cal;
|
||||
|
||||
array_init_size(&zv, 8);
|
||||
|
||||
co = (Calendar_object*)zend_object_store_get_object(object TSRMLS_CC);
|
||||
cal = co->ucal;
|
||||
|
||||
if (cal == NULL) {
|
||||
add_assoc_bool_ex(&zv, "valid", sizeof("valid"), 0);
|
||||
return Z_ARRVAL(zv);
|
||||
}
|
||||
|
||||
add_assoc_bool_ex(&zv, "valid", sizeof("valid"), 1);
|
||||
|
||||
add_assoc_string_ex(&zv, "type", sizeof("type"),
|
||||
const_cast<char*>(cal->getType()), 1);
|
||||
|
||||
{
|
||||
zval ztz = zval_used_for_init,
|
||||
*ztz_debug;
|
||||
int is_tmp;
|
||||
HashTable *debug_info;
|
||||
|
||||
timezone_object_construct(&cal->getTimeZone(), &ztz , 0 TSRMLS_CC);
|
||||
debug_info = Z_OBJ_HANDLER(ztz, get_debug_info)(&ztz, &is_tmp TSRMLS_CC);
|
||||
assert(is_tmp == 1);
|
||||
|
||||
ALLOC_INIT_ZVAL(ztz_debug);
|
||||
Z_TYPE_P(ztz_debug) = IS_ARRAY;
|
||||
Z_ARRVAL_P(ztz_debug) = debug_info;
|
||||
add_assoc_zval_ex(&zv, "timeZone", sizeof("timeZone"), ztz_debug);
|
||||
}
|
||||
|
||||
{
|
||||
UErrorCode uec = U_ZERO_ERROR;
|
||||
Locale locale = cal->getLocale(ULOC_VALID_LOCALE, uec);
|
||||
if (U_SUCCESS(uec)) {
|
||||
add_assoc_string_ex(&zv, "locale", sizeof("locale"),
|
||||
const_cast<char*>(locale.getName()), 1);
|
||||
} else {
|
||||
add_assoc_string_ex(&zv, "locale", sizeof("locale"),
|
||||
const_cast<char*>(u_errorName(uec)), 1);
|
||||
}
|
||||
}
|
||||
|
||||
ALLOC_INIT_ZVAL(zfields);
|
||||
array_init_size(zfields, UCAL_FIELD_COUNT);
|
||||
|
||||
for (int i = 0;
|
||||
i < sizeof(debug_info_fields) / sizeof(*debug_info_fields);
|
||||
i++) {
|
||||
UErrorCode uec = U_ZERO_ERROR;
|
||||
const char *name = debug_info_fields[i].name;
|
||||
int32_t res = cal->get(debug_info_fields[i].field, uec);
|
||||
if (U_SUCCESS(uec)) {
|
||||
add_assoc_long(zfields, name, (long)res);
|
||||
} else {
|
||||
add_assoc_string(zfields, name, const_cast<char*>(u_errorName(uec)), 1);
|
||||
}
|
||||
}
|
||||
|
||||
add_assoc_zval_ex(&zv, "fields", sizeof("fields"), zfields);
|
||||
|
||||
*is_temp = 1;
|
||||
|
||||
return Z_ARRVAL(zv);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ void calendar_object_init(Calendar_object* to)
|
||||
* Initialize internals of Calendar_object not specific to zend standard objects.
|
||||
*/
|
||||
static void calendar_object_init(Calendar_object *co TSRMLS_DC)
|
||||
{
|
||||
intl_error_init(CALENDAR_ERROR_P(co) TSRMLS_CC);
|
||||
co->ucal = NULL;
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ Calendar_objects_dtor */
|
||||
static void Calendar_objects_dtor(void *object,
|
||||
zend_object_handle handle TSRMLS_DC)
|
||||
{
|
||||
zend_objects_destroy_object((zend_object*)object, handle TSRMLS_CC);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ Calendar_objects_free */
|
||||
static void Calendar_objects_free(zend_object *object TSRMLS_DC)
|
||||
{
|
||||
Calendar_object* co = (Calendar_object*) object;
|
||||
|
||||
if (co->ucal) {
|
||||
delete co->ucal;
|
||||
co->ucal = NULL;
|
||||
}
|
||||
intl_error_reset(CALENDAR_ERROR_P(co) TSRMLS_CC);
|
||||
|
||||
zend_object_std_dtor(&co->zo TSRMLS_CC);
|
||||
|
||||
efree(co);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ Calendar_object_create */
|
||||
static zend_object_value Calendar_object_create(zend_class_entry *ce TSRMLS_DC)
|
||||
{
|
||||
zend_object_value retval;
|
||||
Calendar_object* intern;
|
||||
|
||||
intern = (Calendar_object*)ecalloc(1, sizeof(Calendar_object));
|
||||
|
||||
zend_object_std_init(&intern->zo, ce TSRMLS_CC);
|
||||
#if PHP_VERSION_ID < 50399
|
||||
zend_hash_copy(intern->zo.properties, &(ce->default_properties),
|
||||
(copy_ctor_func_t) zval_add_ref, NULL, sizeof(zval*));
|
||||
#else
|
||||
object_properties_init((zend_object*) intern, ce);
|
||||
#endif
|
||||
calendar_object_init(intern TSRMLS_CC);
|
||||
|
||||
retval.handle = zend_objects_store_put(
|
||||
intern,
|
||||
Calendar_objects_dtor,
|
||||
(zend_objects_free_object_storage_t) Calendar_objects_free,
|
||||
NULL TSRMLS_CC);
|
||||
|
||||
retval.handlers = &Calendar_handlers;
|
||||
|
||||
return retval;
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ Calendar methods arguments info */
|
||||
|
||||
ZEND_BEGIN_ARG_INFO_EX(ainfo_cal_void, 0, 0, 0)
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
ZEND_BEGIN_ARG_INFO_EX(ainfo_cal_field, 0, 0, 1)
|
||||
ZEND_ARG_INFO(0, field)
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
ZEND_BEGIN_ARG_INFO_EX(ainfo_cal_dow, 0, 0, 1)
|
||||
ZEND_ARG_INFO(0, dayOfWeek)
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
ZEND_BEGIN_ARG_INFO_EX(ainfo_cal_other_cal, 0, 0, 1)
|
||||
ZEND_ARG_OBJ_INFO(0, calendar, IntlCalendar, 0)
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
ZEND_BEGIN_ARG_INFO_EX(ainfo_cal_date, 0, 0, 1)
|
||||
ZEND_ARG_INFO(0, date)
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
ZEND_BEGIN_ARG_INFO_EX(ainfo_cal_date_optional, 0, 0, 0)
|
||||
ZEND_ARG_INFO(0, date)
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
|
||||
ZEND_BEGIN_ARG_INFO_EX(ainfo_cal_createInstance, 0, 0, 0)
|
||||
ZEND_ARG_INFO(0, timeZone)
|
||||
ZEND_ARG_INFO(0, locale)
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
ZEND_BEGIN_ARG_INFO_EX(ainfo_cal_get_keyword_values_for_locale, 0, 0, 3)
|
||||
ZEND_ARG_INFO(0, key)
|
||||
ZEND_ARG_INFO(0, locale)
|
||||
ZEND_ARG_INFO(0, commonlyUsed)
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
ZEND_BEGIN_ARG_INFO_EX(ainfo_cal_add, 0, 0, 2)
|
||||
ZEND_ARG_INFO(0, field)
|
||||
ZEND_ARG_INFO(0, amount)
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
ZEND_BEGIN_ARG_INFO_EX(ainfo_cal_setTimeZone, 0, 0, 2)
|
||||
ZEND_ARG_OBJ_INFO(0, timeZone, IntlTimeZone, 1)
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
ZEND_BEGIN_ARG_INFO_EX(ainfo_cal_set, 0, 0, 2)
|
||||
ZEND_ARG_INFO(0, fieldOrYear)
|
||||
ZEND_ARG_INFO(0, valueOrMonth)
|
||||
ZEND_ARG_INFO(0, dayOfMonth)
|
||||
ZEND_ARG_INFO(0, hour)
|
||||
ZEND_ARG_INFO(0, minute)
|
||||
ZEND_ARG_INFO(0, second)
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
ZEND_BEGIN_ARG_INFO_EX(ainfo_cal_roll, 0, 0, 2)
|
||||
ZEND_ARG_INFO(0, field)
|
||||
ZEND_ARG_INFO(0, amountOrUpOrDown)
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
ZEND_BEGIN_ARG_INFO_EX(ainfo_cal_clear, 0, 0, 0)
|
||||
ZEND_ARG_INFO(0, field)
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
ZEND_BEGIN_ARG_INFO_EX(ainfo_cal_field_difference, 0, 0, 2)
|
||||
ZEND_ARG_INFO(0, when)
|
||||
ZEND_ARG_INFO(0, field)
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
ZEND_BEGIN_ARG_INFO_EX(ainfo_cal_get_locale, 0, 0, 1)
|
||||
ZEND_ARG_INFO(0, localeType)
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
ZEND_BEGIN_ARG_INFO_EX(ainfo_cal_setLenient, 0, 0, 1)
|
||||
ZEND_ARG_INFO(0, isLenient)
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
ZEND_BEGIN_ARG_INFO_EX(ainfo_cal_wall_time_option, 0, 0, 1)
|
||||
ZEND_ARG_INFO(0, wallTimeOption)
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
/* Gregorian Calendar */
|
||||
ZEND_BEGIN_ARG_INFO_EX(ainfo_gregcal___construct, 0, 0, 0)
|
||||
ZEND_ARG_INFO(0, timeZoneOrYear)
|
||||
ZEND_ARG_INFO(0, localeOrMonth)
|
||||
ZEND_ARG_INFO(0, dayOfMonth)
|
||||
ZEND_ARG_INFO(0, hour)
|
||||
ZEND_ARG_INFO(0, minute)
|
||||
ZEND_ARG_INFO(0, second)
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
ZEND_BEGIN_ARG_INFO_EX(ainfo_gregcal_isLeapYear, 0, 0, 1)
|
||||
ZEND_ARG_INFO(0, year)
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
/* }}} */
|
||||
|
||||
/* {{{ Calendar_class_functions
|
||||
* Every 'IntlCalendar' class method has an entry in this table
|
||||
*/
|
||||
static const zend_function_entry Calendar_class_functions[] = {
|
||||
PHP_ME(IntlCalendar, __construct, ainfo_cal_void, ZEND_ACC_PRIVATE)
|
||||
PHP_ME_MAPPING(createInstance, intlcal_create_instance, ainfo_cal_createInstance, ZEND_ACC_STATIC | ZEND_ACC_PUBLIC)
|
||||
#if U_ICU_VERSION_MAJOR_NUM * 10 + U_ICU_VERSION_MINOR_NUM >= 42
|
||||
PHP_ME_MAPPING(getKeywordValuesForLocale, intlcal_get_keyword_values_for_locale, ainfo_cal_get_keyword_values_for_locale, ZEND_ACC_STATIC | ZEND_ACC_PUBLIC)
|
||||
#endif
|
||||
PHP_ME_MAPPING(getNow, intlcal_get_now, ainfo_cal_void, ZEND_ACC_STATIC | ZEND_ACC_PUBLIC)
|
||||
PHP_ME_MAPPING(getAvailableLocales, intlcal_get_available_locales, ainfo_cal_void, ZEND_ACC_STATIC | ZEND_ACC_PUBLIC)
|
||||
PHP_ME_MAPPING(get, intlcal_get, ainfo_cal_field, ZEND_ACC_PUBLIC)
|
||||
PHP_ME_MAPPING(getTime, intlcal_get_time, ainfo_cal_void, ZEND_ACC_PUBLIC)
|
||||
PHP_ME_MAPPING(setTime, intlcal_set_time, ainfo_cal_date, ZEND_ACC_PUBLIC)
|
||||
PHP_ME_MAPPING(add, intlcal_add, ainfo_cal_add, ZEND_ACC_PUBLIC)
|
||||
PHP_ME_MAPPING(setTimeZone, intlcal_set_time_zone, ainfo_cal_setTimeZone, ZEND_ACC_PUBLIC)
|
||||
PHP_ME_MAPPING(after, intlcal_after, ainfo_cal_other_cal, ZEND_ACC_PUBLIC)
|
||||
PHP_ME_MAPPING(before, intlcal_before, ainfo_cal_other_cal, ZEND_ACC_PUBLIC)
|
||||
PHP_ME_MAPPING(set, intlcal_set, ainfo_cal_set, ZEND_ACC_PUBLIC)
|
||||
PHP_ME_MAPPING(roll, intlcal_roll, ainfo_cal_roll, ZEND_ACC_PUBLIC)
|
||||
PHP_ME_MAPPING(clear, intlcal_clear, ainfo_cal_clear, ZEND_ACC_PUBLIC)
|
||||
PHP_ME_MAPPING(fieldDifference, intlcal_field_difference, ainfo_cal_field_difference, ZEND_ACC_PUBLIC)
|
||||
PHP_ME_MAPPING(getActualMaximum, intlcal_get_actual_maximum, ainfo_cal_field, ZEND_ACC_PUBLIC)
|
||||
PHP_ME_MAPPING(getActualMinimum, intlcal_get_actual_minimum, ainfo_cal_field, ZEND_ACC_PUBLIC)
|
||||
#if U_ICU_VERSION_MAJOR_NUM * 10 + U_ICU_VERSION_MINOR_NUM >= 44
|
||||
PHP_ME_MAPPING(getDayOfWeekType, intlcal_get_day_of_week_type, ainfo_cal_dow, ZEND_ACC_PUBLIC)
|
||||
#endif
|
||||
PHP_ME_MAPPING(getFirstDayOfWeek, intlcal_get_first_day_of_week, ainfo_cal_void, ZEND_ACC_PUBLIC)
|
||||
PHP_ME_MAPPING(getGreatestMinimum, intlcal_get_greatest_minimum, ainfo_cal_field, ZEND_ACC_PUBLIC)
|
||||
PHP_ME_MAPPING(getLeastMaximum, intlcal_get_least_maximum, ainfo_cal_field, ZEND_ACC_PUBLIC)
|
||||
PHP_ME_MAPPING(getLocale, intlcal_get_locale, ainfo_cal_get_locale, ZEND_ACC_PUBLIC)
|
||||
PHP_ME_MAPPING(getMaximum, intlcal_get_maximum, ainfo_cal_field, ZEND_ACC_PUBLIC)
|
||||
PHP_ME_MAPPING(getMinimalDaysInFirstWeek, intlcal_get_minimal_days_in_first_week, ainfo_cal_void, ZEND_ACC_PUBLIC)
|
||||
PHP_ME_MAPPING(getMinimum, intlcal_get_minimum, ainfo_cal_field, ZEND_ACC_PUBLIC)
|
||||
PHP_ME_MAPPING(getTimeZone, intlcal_get_time_zone, ainfo_cal_void, ZEND_ACC_PUBLIC)
|
||||
PHP_ME_MAPPING(getType, intlcal_get_type, ainfo_cal_void, ZEND_ACC_PUBLIC)
|
||||
#if U_ICU_VERSION_MAJOR_NUM * 10 + U_ICU_VERSION_MINOR_NUM >= 44
|
||||
PHP_ME_MAPPING(getWeekendTransition,intlcal_get_weekend_transition, ainfo_cal_dow, ZEND_ACC_PUBLIC)
|
||||
#endif
|
||||
PHP_ME_MAPPING(inDaylightTime, intlcal_in_daylight_time, ainfo_cal_void, ZEND_ACC_PUBLIC)
|
||||
PHP_ME_MAPPING(isEquivalentTo, intlcal_is_equivalent_to, ainfo_cal_other_cal, ZEND_ACC_PUBLIC)
|
||||
PHP_ME_MAPPING(isLenient, intlcal_is_lenient, ainfo_cal_void, ZEND_ACC_PUBLIC)
|
||||
PHP_ME_MAPPING(isSet, intlcal_is_set, ainfo_cal_field, ZEND_ACC_PUBLIC)
|
||||
#if U_ICU_VERSION_MAJOR_NUM * 10 + U_ICU_VERSION_MINOR_NUM >= 44
|
||||
PHP_ME_MAPPING(isWeekend, intlcal_is_weekend, ainfo_cal_date_optional, ZEND_ACC_PUBLIC)
|
||||
#endif
|
||||
PHP_ME_MAPPING(setFirstDayOfWeek, intlcal_set_first_day_of_week, ainfo_cal_dow, ZEND_ACC_PUBLIC)
|
||||
PHP_ME_MAPPING(setLenient, intlcal_set_lenient, ainfo_cal_setLenient, ZEND_ACC_PUBLIC)
|
||||
PHP_ME_MAPPING(equals, intlcal_equals, ainfo_cal_other_cal, ZEND_ACC_PUBLIC)
|
||||
#if U_ICU_VERSION_MAJOR_NUM >= 49
|
||||
PHP_ME_MAPPING(getRepeatedWallTimeOption,intlcal_get_repeated_wall_time_option,ainfo_cal_void, ZEND_ACC_PUBLIC)
|
||||
PHP_ME_MAPPING(getSkippedWallTimeOption,intlcal_get_skipped_wall_time_option,ainfo_cal_void, ZEND_ACC_PUBLIC)
|
||||
PHP_ME_MAPPING(setRepeatedWallTimeOption,intlcal_set_repeated_wall_time_option,ainfo_cal_wall_time_option,ZEND_ACC_PUBLIC)
|
||||
PHP_ME_MAPPING(setSkippedWallTimeOption,intlcal_set_skipped_wall_time_option,ainfo_cal_wall_time_option,ZEND_ACC_PUBLIC)
|
||||
#endif
|
||||
PHP_ME_MAPPING(getErrorCode, intlcal_get_error_code, ainfo_cal_void, ZEND_ACC_PUBLIC)
|
||||
PHP_ME_MAPPING(getErrorMessage, intlcal_get_error_message, ainfo_cal_void, ZEND_ACC_PUBLIC)
|
||||
PHP_FE_END
|
||||
};
|
||||
/* }}} */
|
||||
|
||||
/* {{{ GregorianCalendar_class_functions
|
||||
*/
|
||||
static const zend_function_entry GregorianCalendar_class_functions[] = {
|
||||
PHP_ME(IntlGregorianCalendar, __construct, ainfo_gregcal___construct, ZEND_ACC_PUBLIC)
|
||||
PHP_ME_MAPPING(setGregorianChange, intlgregcal_set_gregorian_change, ainfo_cal_date, ZEND_ACC_PUBLIC)
|
||||
PHP_ME_MAPPING(getGregorianChange, intlgregcal_get_gregorian_change, ainfo_cal_void, ZEND_ACC_PUBLIC)
|
||||
PHP_ME_MAPPING(isLeapYear, intlgregcal_is_leap_year, ainfo_gregcal_isLeapYear, ZEND_ACC_PUBLIC)
|
||||
PHP_FE_END
|
||||
};
|
||||
/* }}} */
|
||||
|
||||
|
||||
/* {{{ calendar_register_IntlCalendar_class
|
||||
* Initialize 'IntlCalendar' class
|
||||
*/
|
||||
void calendar_register_IntlCalendar_class(TSRMLS_D)
|
||||
{
|
||||
zend_class_entry ce;
|
||||
|
||||
/* Create and register 'IntlCalendar' class. */
|
||||
INIT_CLASS_ENTRY(ce, "IntlCalendar", Calendar_class_functions);
|
||||
ce.create_object = Calendar_object_create;
|
||||
Calendar_ce_ptr = zend_register_internal_class(&ce TSRMLS_CC);
|
||||
if (!Calendar_ce_ptr) {
|
||||
//can't happen now without bigger problems before
|
||||
php_error_docref0(NULL TSRMLS_CC, E_ERROR,
|
||||
"IntlCalendar: class registration has failed.");
|
||||
return;
|
||||
}
|
||||
memcpy( &Calendar_handlers, zend_get_std_object_handlers(),
|
||||
sizeof Calendar_handlers);
|
||||
Calendar_handlers.clone_obj = Calendar_clone_obj;
|
||||
Calendar_handlers.get_debug_info = Calendar_get_debug_info;
|
||||
|
||||
/* Create and register 'IntlGregorianCalendar' class. */
|
||||
INIT_CLASS_ENTRY(ce, "IntlGregorianCalendar", GregorianCalendar_class_functions);
|
||||
GregorianCalendar_ce_ptr = zend_register_internal_class_ex(&ce,
|
||||
Calendar_ce_ptr, NULL TSRMLS_CC);
|
||||
if (!GregorianCalendar_ce_ptr) {
|
||||
//can't happen know without bigger problems before
|
||||
php_error_docref0(NULL TSRMLS_CC, E_ERROR,
|
||||
"IntlGregorianCalendar: class registration has failed.");
|
||||
return;
|
||||
}
|
||||
|
||||
/* Declare 'IntlCalendar' class constants */
|
||||
#define CALENDAR_DECL_LONG_CONST(name, val) \
|
||||
zend_declare_class_constant_long(Calendar_ce_ptr, name, sizeof(name) - 1, \
|
||||
val TSRMLS_CC)
|
||||
|
||||
CALENDAR_DECL_LONG_CONST("FIELD_ERA", UCAL_ERA);
|
||||
CALENDAR_DECL_LONG_CONST("FIELD_YEAR", UCAL_YEAR);
|
||||
CALENDAR_DECL_LONG_CONST("FIELD_MONTH", UCAL_MONTH);
|
||||
CALENDAR_DECL_LONG_CONST("FIELD_WEEK_OF_YEAR", UCAL_WEEK_OF_YEAR);
|
||||
CALENDAR_DECL_LONG_CONST("FIELD_WEEK_OF_MONTH", UCAL_WEEK_OF_MONTH);
|
||||
CALENDAR_DECL_LONG_CONST("FIELD_DATE", UCAL_DATE);
|
||||
CALENDAR_DECL_LONG_CONST("FIELD_DAY_OF_YEAR", UCAL_DAY_OF_YEAR);
|
||||
CALENDAR_DECL_LONG_CONST("FIELD_DAY_OF_WEEK", UCAL_DAY_OF_WEEK);
|
||||
CALENDAR_DECL_LONG_CONST("FIELD_DAY_OF_WEEK_IN_MONTH", UCAL_DAY_OF_WEEK_IN_MONTH);
|
||||
CALENDAR_DECL_LONG_CONST("FIELD_AM_PM", UCAL_AM_PM);
|
||||
CALENDAR_DECL_LONG_CONST("FIELD_HOUR", UCAL_HOUR);
|
||||
CALENDAR_DECL_LONG_CONST("FIELD_HOUR_OF_DAY", UCAL_HOUR_OF_DAY);
|
||||
CALENDAR_DECL_LONG_CONST("FIELD_HOUR", UCAL_HOUR);
|
||||
CALENDAR_DECL_LONG_CONST("FIELD_HOUR_OF_DAY", UCAL_HOUR_OF_DAY);
|
||||
CALENDAR_DECL_LONG_CONST("FIELD_MINUTE", UCAL_MINUTE);
|
||||
CALENDAR_DECL_LONG_CONST("FIELD_SECOND", UCAL_SECOND);
|
||||
CALENDAR_DECL_LONG_CONST("FIELD_MILLISECOND", UCAL_MILLISECOND);
|
||||
CALENDAR_DECL_LONG_CONST("FIELD_ZONE_OFFSET", UCAL_ZONE_OFFSET);
|
||||
CALENDAR_DECL_LONG_CONST("FIELD_DST_OFFSET", UCAL_DST_OFFSET);
|
||||
CALENDAR_DECL_LONG_CONST("FIELD_YEAR_WOY", UCAL_YEAR_WOY);
|
||||
CALENDAR_DECL_LONG_CONST("FIELD_DOW_LOCAL", UCAL_DOW_LOCAL);
|
||||
CALENDAR_DECL_LONG_CONST("FIELD_EXTENDED_YEAR", UCAL_EXTENDED_YEAR);
|
||||
CALENDAR_DECL_LONG_CONST("FIELD_JULIAN_DAY", UCAL_JULIAN_DAY);
|
||||
CALENDAR_DECL_LONG_CONST("FIELD_MILLISECONDS_IN_DAY", UCAL_MILLISECONDS_IN_DAY);
|
||||
CALENDAR_DECL_LONG_CONST("FIELD_IS_LEAP_MONTH", UCAL_IS_LEAP_MONTH);
|
||||
CALENDAR_DECL_LONG_CONST("FIELD_FIELD_COUNT ", UCAL_FIELD_COUNT);
|
||||
CALENDAR_DECL_LONG_CONST("FIELD_DAY_OF_MONTH", UCAL_DAY_OF_MONTH);
|
||||
|
||||
CALENDAR_DECL_LONG_CONST("DOW_SUNDAY", UCAL_SUNDAY);
|
||||
CALENDAR_DECL_LONG_CONST("DOW_MONDAY", UCAL_MONDAY);
|
||||
CALENDAR_DECL_LONG_CONST("DOW_TUESDAY", UCAL_TUESDAY);
|
||||
CALENDAR_DECL_LONG_CONST("DOW_WEDNESDAY", UCAL_WEDNESDAY);
|
||||
CALENDAR_DECL_LONG_CONST("DOW_THURSDAY", UCAL_THURSDAY);
|
||||
CALENDAR_DECL_LONG_CONST("DOW_FRIDAY", UCAL_FRIDAY);
|
||||
CALENDAR_DECL_LONG_CONST("DOW_SATURDAY", UCAL_SATURDAY);
|
||||
|
||||
#if U_ICU_VERSION_MAJOR_NUM * 10 + U_ICU_VERSION_MINOR_NUM >= 44
|
||||
CALENDAR_DECL_LONG_CONST("DOW_TYPE_WEEKDAY", UCAL_WEEKDAY);
|
||||
CALENDAR_DECL_LONG_CONST("DOW_TYPE_WEEKEND", UCAL_WEEKEND);
|
||||
CALENDAR_DECL_LONG_CONST("DOW_TYPE_WEEKEND_OFFSET", UCAL_WEEKEND_ONSET);
|
||||
CALENDAR_DECL_LONG_CONST("DOW_TYPE_WEEKEND_CEASE", UCAL_WEEKEND_CEASE);
|
||||
#endif
|
||||
|
||||
#if U_ICU_VERSION_MAJOR_NUM >= 49
|
||||
CALENDAR_DECL_LONG_CONST("WALLTIME_FIRST", UCAL_WALLTIME_FIRST);
|
||||
CALENDAR_DECL_LONG_CONST("WALLTIME_LAST", UCAL_WALLTIME_LAST);
|
||||
CALENDAR_DECL_LONG_CONST("WALLTIME_NEXT_VALID", UCAL_WALLTIME_NEXT_VALID);
|
||||
#endif
|
||||
}
|
||||
/* }}} */
|
67
ext/intl/calendar/calendar_class.h
Normal file
67
ext/intl/calendar/calendar_class.h
Normal file
@ -0,0 +1,67 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| PHP Version 5 |
|
||||
+----------------------------------------------------------------------+
|
||||
| This source file is subject to version 3.01 of the PHP license, |
|
||||
| that is bundled with this package in the file LICENSE, and is |
|
||||
| available through the world-wide-web at the following url: |
|
||||
| http://www.php.net/license/3_01.txt |
|
||||
| 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. |
|
||||
+----------------------------------------------------------------------+
|
||||
| Authors: Gustavo Lopes <cataphract@php.net> |
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
#ifndef CALENDAR_CLASS_H
|
||||
#define CALENDAR_CLASS_H
|
||||
|
||||
//redefinition of inline in PHP headers causes problems, so include this before
|
||||
#include <math.h>
|
||||
|
||||
#include <php.h>
|
||||
#include "intl_error.h"
|
||||
#include "intl_data.h"
|
||||
|
||||
#ifndef USE_CALENDAR_POINTER
|
||||
typedef void Calendar;
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
zend_object zo;
|
||||
|
||||
// error handling
|
||||
intl_error err;
|
||||
|
||||
// ICU calendar
|
||||
Calendar* ucal;
|
||||
} Calendar_object;
|
||||
|
||||
#define CALENDAR_ERROR(co) (co)->err
|
||||
#define CALENDAR_ERROR_P(co) &(CALENDAR_ERROR(co))
|
||||
|
||||
#define CALENDAR_ERROR_CODE(co) INTL_ERROR_CODE(CALENDAR_ERROR(co))
|
||||
#define CALENDAR_ERROR_CODE_P(co) &(INTL_ERROR_CODE(CALENDAR_ERROR(co)))
|
||||
|
||||
#define CALENDAR_METHOD_INIT_VARS INTL_METHOD_INIT_VARS(Calendar, co)
|
||||
#define CALENDAR_METHOD_FETCH_OBJECT_NO_CHECK INTL_METHOD_FETCH_OBJECT(Calendar, co)
|
||||
#define CALENDAR_METHOD_FETCH_OBJECT \
|
||||
CALENDAR_METHOD_FETCH_OBJECT_NO_CHECK; \
|
||||
if (co->ucal == NULL) \
|
||||
{ \
|
||||
intl_errors_set(&co->err, U_ILLEGAL_ARGUMENT_ERROR, "Found unconstructed IntlCalendar", 0 TSRMLS_CC); \
|
||||
RETURN_FALSE; \
|
||||
}
|
||||
|
||||
void calendar_object_create(zval *object, Calendar *calendar TSRMLS_DC);
|
||||
|
||||
void calendar_object_construct(zval *object, Calendar *calendar TSRMLS_DC);
|
||||
|
||||
void calendar_register_IntlCalendar_class(TSRMLS_D);
|
||||
|
||||
extern zend_class_entry *Calendar_ce_ptr,
|
||||
*GregorianCalendar_ce_ptr;
|
||||
extern zend_object_handlers Calendar_handlers;
|
||||
|
||||
#endif /* #ifndef CALENDAR_CLASS_H */
|
1157
ext/intl/calendar/calendar_methods.cpp
Normal file
1157
ext/intl/calendar/calendar_methods.cpp
Normal file
File diff suppressed because it is too large
Load Diff
108
ext/intl/calendar/calendar_methods.h
Normal file
108
ext/intl/calendar/calendar_methods.h
Normal file
@ -0,0 +1,108 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| PHP Version 5 |
|
||||
+----------------------------------------------------------------------+
|
||||
| This source file is subject to version 3.01 of the PHP license, |
|
||||
| that is bundled with this package in the file LICENSE, and is |
|
||||
| available through the world-wide-web at the following url: |
|
||||
| http://www.php.net/license/3_01.txt |
|
||||
| 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. |
|
||||
+----------------------------------------------------------------------+
|
||||
| Authors: Gustavo Lopes <cataphract@netcabo.pt> |
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
#ifndef CALENDAR_METHODS_H
|
||||
#define CALENDAR_METHODS_H
|
||||
|
||||
#include <php.h>
|
||||
|
||||
PHP_METHOD(IntlCalendar, __construct);
|
||||
|
||||
PHP_FUNCTION(intlcal_create_instance);
|
||||
|
||||
PHP_FUNCTION(intlcal_get_keyword_values_for_locale);
|
||||
|
||||
PHP_FUNCTION(intlcal_get_now);
|
||||
|
||||
PHP_FUNCTION(intlcal_get_available_locales);
|
||||
|
||||
PHP_FUNCTION(intlcal_get);
|
||||
|
||||
PHP_FUNCTION(intlcal_get_time);
|
||||
|
||||
PHP_FUNCTION(intlcal_set_time);
|
||||
|
||||
PHP_FUNCTION(intlcal_add);
|
||||
|
||||
PHP_FUNCTION(intlcal_set_time_zone);
|
||||
|
||||
PHP_FUNCTION(intlcal_after);
|
||||
|
||||
PHP_FUNCTION(intlcal_before);
|
||||
|
||||
PHP_FUNCTION(intlcal_set);
|
||||
|
||||
PHP_FUNCTION(intlcal_roll);
|
||||
|
||||
PHP_FUNCTION(intlcal_clear);
|
||||
|
||||
PHP_FUNCTION(intlcal_field_difference);
|
||||
|
||||
PHP_FUNCTION(intlcal_get_actual_maximum);
|
||||
|
||||
PHP_FUNCTION(intlcal_get_actual_minimum);
|
||||
|
||||
PHP_FUNCTION(intlcal_get_day_of_week_type);
|
||||
|
||||
PHP_FUNCTION(intlcal_get_first_day_of_week);
|
||||
|
||||
PHP_FUNCTION(intlcal_get_greatest_minimum);
|
||||
|
||||
PHP_FUNCTION(intlcal_get_least_maximum);
|
||||
|
||||
PHP_FUNCTION(intlcal_get_locale);
|
||||
|
||||
PHP_FUNCTION(intlcal_get_maximum);
|
||||
|
||||
PHP_FUNCTION(intlcal_get_minimal_days_in_first_week);
|
||||
|
||||
PHP_FUNCTION(intlcal_get_minimum);
|
||||
|
||||
PHP_FUNCTION(intlcal_get_time_zone);
|
||||
|
||||
PHP_FUNCTION(intlcal_get_type);
|
||||
|
||||
PHP_FUNCTION(intlcal_get_weekend_transition);
|
||||
|
||||
PHP_FUNCTION(intlcal_in_daylight_time);
|
||||
|
||||
PHP_FUNCTION(intlcal_is_equivalent_to);
|
||||
|
||||
PHP_FUNCTION(intlcal_is_lenient);
|
||||
|
||||
PHP_FUNCTION(intlcal_is_set);
|
||||
|
||||
PHP_FUNCTION(intlcal_is_weekend);
|
||||
|
||||
PHP_FUNCTION(intlcal_set_first_day_of_week);
|
||||
|
||||
PHP_FUNCTION(intlcal_set_lenient);
|
||||
|
||||
PHP_FUNCTION(intlcal_equals);
|
||||
|
||||
PHP_FUNCTION(intlcal_get_repeated_wall_time_option);
|
||||
|
||||
PHP_FUNCTION(intlcal_get_skipped_wall_time_option);
|
||||
|
||||
PHP_FUNCTION(intlcal_set_repeated_wall_time_option);
|
||||
|
||||
PHP_FUNCTION(intlcal_set_skipped_wall_time_option);
|
||||
|
||||
PHP_FUNCTION(intlcal_get_error_code);
|
||||
|
||||
PHP_FUNCTION(intlcal_get_error_message);
|
||||
|
||||
#endif /* #ifndef CALENDAR_METHODS_H */
|
256
ext/intl/calendar/gregoriancalendar_methods.cpp
Normal file
256
ext/intl/calendar/gregoriancalendar_methods.cpp
Normal file
@ -0,0 +1,256 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| PHP Version 5 |
|
||||
+----------------------------------------------------------------------+
|
||||
| This source file is subject to version 3.01 of the PHP license, |
|
||||
| that is bundled with this package in the file LICENSE, and is |
|
||||
| available through the world-wide-web at the following url: |
|
||||
| http://www.php.net/license/3_01.txt |
|
||||
| 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. |
|
||||
+----------------------------------------------------------------------+
|
||||
| Authors: Gustavo Lopes <cataphract@php.net> |
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <unicode/locid.h>
|
||||
#include <unicode/calendar.h>
|
||||
#include <unicode/gregocal.h>
|
||||
extern "C" {
|
||||
#define USE_TIMEZONE_POINTER 1
|
||||
#include "../timezone/timezone_class.h"
|
||||
#define USE_CALENDAR_POINTER 1
|
||||
#include "calendar_class.h"
|
||||
#include "../locale/locale.h"
|
||||
/* avoid redefinition of int8_t, already defined in unicode/pwin32.h */
|
||||
#define _MSC_STDINT_H_ 1
|
||||
#include <ext/date/php_date.h>
|
||||
}
|
||||
|
||||
static inline GregorianCalendar *fetch_greg(Calendar_object *co) {
|
||||
return (GregorianCalendar*)co->ucal;
|
||||
}
|
||||
|
||||
static void _php_intlgregcal_constructor_body(INTERNAL_FUNCTION_PARAMETERS)
|
||||
{
|
||||
zval *object = getThis();
|
||||
zval **tz_object = NULL;
|
||||
zval **args_a[6] = {0},
|
||||
***args = &args_a[0];
|
||||
char *locale = NULL;
|
||||
int locale_len;
|
||||
long largs[6];
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
int variant;
|
||||
intl_error_reset(NULL TSRMLS_CC);
|
||||
|
||||
// parameter number validation / variant determination
|
||||
if (ZEND_NUM_ARGS() > 6 ||
|
||||
zend_get_parameters_array_ex(ZEND_NUM_ARGS(), args) == FAILURE) {
|
||||
intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
|
||||
"intlgregcal_create_instance: too many arguments", 0 TSRMLS_CC);
|
||||
RETURN_NULL();
|
||||
}
|
||||
for (variant = ZEND_NUM_ARGS();
|
||||
variant > 0 && Z_TYPE_PP(args[variant - 1]) == IS_NULL;
|
||||
variant--) {}
|
||||
if (variant == 4) {
|
||||
intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
|
||||
"intlgregcal_create_instance: no variant with 4 arguments "
|
||||
"(excluding trailing NULLs)", 0 TSRMLS_CC);
|
||||
RETURN_NULL();
|
||||
}
|
||||
|
||||
// argument parsing
|
||||
if (variant <= 2) {
|
||||
if (zend_parse_parameters(MIN(ZEND_NUM_ARGS(), 2) TSRMLS_CC,
|
||||
"|Z!s!", &tz_object, &locale, &locale_len) == FAILURE) {
|
||||
intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
|
||||
"intlgregcal_create_instance: bad arguments", 0 TSRMLS_CC);
|
||||
RETURN_NULL();
|
||||
}
|
||||
}
|
||||
if (variant > 2 && zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
|
||||
"lll|lll", &largs[0], &largs[1], &largs[2], &largs[3], &largs[4],
|
||||
&largs[5]) == FAILURE) {
|
||||
intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
|
||||
"intlgregcal_create_instance: bad arguments", 0 TSRMLS_CC);
|
||||
RETURN_NULL();
|
||||
}
|
||||
|
||||
// instantion of ICU object
|
||||
GregorianCalendar *gcal;
|
||||
|
||||
if (variant <= 2) {
|
||||
// From timezone and locale (0 to 2 arguments)
|
||||
TimeZone *tz = timezone_process_timezone_argument(tz_object,
|
||||
"intlgregcal_create_instance" TSRMLS_CC);
|
||||
if (tz == NULL) {
|
||||
RETURN_NULL();
|
||||
}
|
||||
if (!locale) {
|
||||
locale = const_cast<char*>(intl_locale_get_default(TSRMLS_C));
|
||||
}
|
||||
|
||||
gcal = new GregorianCalendar(tz, Locale::createFromName(locale),
|
||||
status);
|
||||
if (U_FAILURE(status)) {
|
||||
intl_error_set(NULL, status, "intlgregcal_create_instance: error "
|
||||
"creating ICU GregorianCalendar from time zone and locale", 0 TSRMLS_CC);
|
||||
if (gcal) {
|
||||
delete gcal;
|
||||
}
|
||||
delete tz;
|
||||
RETURN_NULL();
|
||||
}
|
||||
} else {
|
||||
// From date/time (3, 5 or 6 arguments)
|
||||
for (int i = 0; i < variant; i++) {
|
||||
if (largs[i] < INT32_MIN || largs[i] > INT32_MAX) {
|
||||
intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
|
||||
"intlgregcal_create_instance: at least one of the arguments"
|
||||
" has an absolute value that is too large", 0 TSRMLS_CC);
|
||||
RETURN_NULL();
|
||||
}
|
||||
}
|
||||
|
||||
if (variant == 3) {
|
||||
gcal = new GregorianCalendar((int32_t)largs[0], (int32_t)largs[1],
|
||||
(int32_t)largs[2], status);
|
||||
} else if (variant == 5) {
|
||||
gcal = new GregorianCalendar((int32_t)largs[0], (int32_t)largs[1],
|
||||
(int32_t)largs[2], (int32_t)largs[3], (int32_t)largs[4], status);
|
||||
} else if (variant == 6) {
|
||||
gcal = new GregorianCalendar((int32_t)largs[0], (int32_t)largs[1],
|
||||
(int32_t)largs[2], (int32_t)largs[3], (int32_t)largs[4], (int32_t)largs[5],
|
||||
status);
|
||||
}
|
||||
if (U_FAILURE(status)) {
|
||||
intl_error_set(NULL, status, "intlgregcal_create_instance: error "
|
||||
"creating ICU GregorianCalendar from date", 0 TSRMLS_CC);
|
||||
if (gcal) {
|
||||
delete gcal;
|
||||
}
|
||||
RETURN_NULL();
|
||||
}
|
||||
|
||||
timelib_tzinfo *tzinfo = get_timezone_info(TSRMLS_C);
|
||||
#if U_ICU_VERSION_MAJOR_NUM * 10 + U_ICU_VERSION_MINOR_NUM >= 42
|
||||
UnicodeString tzstr = UnicodeString::fromUTF8(StringPiece(tzinfo->name));
|
||||
#else
|
||||
UnicodeString tzstr = UnicodeString(tzinfo->name,
|
||||
strlen(tzinfo->name), US_INV);
|
||||
#endif
|
||||
if (tzstr.isBogus()) {
|
||||
intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
|
||||
"intlgregcal_create_instance: could not create UTF-8 string "
|
||||
"from PHP's default timezone name (see date_default_timezone_get())",
|
||||
0 TSRMLS_CC);
|
||||
delete gcal;
|
||||
RETURN_NULL();
|
||||
}
|
||||
|
||||
TimeZone *tz = TimeZone::createTimeZone(tzstr);
|
||||
gcal->adoptTimeZone(tz);
|
||||
}
|
||||
|
||||
Calendar_object *co = (Calendar_object*)zend_object_store_get_object(
|
||||
return_value TSRMLS_CC);
|
||||
co->ucal = gcal;
|
||||
}
|
||||
|
||||
U_CFUNC PHP_FUNCTION(intlgregcal_create_instance)
|
||||
{
|
||||
zval orig;
|
||||
intl_error_reset(NULL TSRMLS_CC);
|
||||
|
||||
object_init_ex(return_value, GregorianCalendar_ce_ptr);
|
||||
orig = *return_value;
|
||||
|
||||
_php_intlgregcal_constructor_body(INTERNAL_FUNCTION_PARAM_PASSTHRU);
|
||||
|
||||
if (Z_TYPE_P(return_value) == IS_NULL) {
|
||||
zend_object_store_ctor_failed(&orig TSRMLS_CC);
|
||||
zval_dtor(&orig);
|
||||
}
|
||||
}
|
||||
|
||||
U_CFUNC PHP_METHOD(IntlGregorianCalendar, __construct)
|
||||
{
|
||||
zval orig_this = *getThis();
|
||||
intl_error_reset(NULL TSRMLS_CC);
|
||||
|
||||
return_value = getThis();
|
||||
//changes this to IS_NULL (without first destroying) if there's an error
|
||||
_php_intlgregcal_constructor_body(INTERNAL_FUNCTION_PARAM_PASSTHRU);
|
||||
|
||||
if (Z_TYPE_P(return_value) == IS_NULL) {
|
||||
zend_object_store_ctor_failed(&orig_this TSRMLS_CC);
|
||||
zval_dtor(&orig_this);
|
||||
}
|
||||
}
|
||||
|
||||
U_CFUNC PHP_FUNCTION(intlgregcal_set_gregorian_change)
|
||||
{
|
||||
double date;
|
||||
CALENDAR_METHOD_INIT_VARS;
|
||||
|
||||
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(),
|
||||
"Od", &object, GregorianCalendar_ce_ptr, &date) == FAILURE) {
|
||||
intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
|
||||
"intlgregcal_set_gregorian_change: bad arguments", 0 TSRMLS_CC);
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
CALENDAR_METHOD_FETCH_OBJECT;
|
||||
|
||||
fetch_greg(co)->setGregorianChange(date, CALENDAR_ERROR_CODE(co));
|
||||
INTL_METHOD_CHECK_STATUS(co, "intlgregcal_set_gregorian_change: error "
|
||||
"calling ICU method");
|
||||
|
||||
RETURN_TRUE;
|
||||
}
|
||||
|
||||
U_CFUNC PHP_FUNCTION(intlgregcal_get_gregorian_change)
|
||||
{
|
||||
CALENDAR_METHOD_INIT_VARS;
|
||||
|
||||
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(),
|
||||
"O", &object, GregorianCalendar_ce_ptr) == FAILURE) {
|
||||
intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
|
||||
"intlgregcal_get_gregorian_change: bad arguments", 0 TSRMLS_CC);
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
CALENDAR_METHOD_FETCH_OBJECT;
|
||||
|
||||
RETURN_DOUBLE((double)fetch_greg(co)->getGregorianChange());
|
||||
}
|
||||
|
||||
U_CFUNC PHP_FUNCTION(intlgregcal_is_leap_year)
|
||||
{
|
||||
long year;
|
||||
CALENDAR_METHOD_INIT_VARS;
|
||||
|
||||
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(),
|
||||
"Ol", &object, GregorianCalendar_ce_ptr, &year) == FAILURE) {
|
||||
intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
|
||||
"intlgregcal_is_leap_year: bad arguments", 0 TSRMLS_CC);
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
if (year < INT32_MIN || year > INT32_MAX) {
|
||||
intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
|
||||
"intlgregcal_is_leap_year: year out of bounds", 0 TSRMLS_CC);
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
CALENDAR_METHOD_FETCH_OBJECT;
|
||||
|
||||
RETURN_BOOL((int)fetch_greg(co)->isLeapYear((int32_t)year));
|
||||
}
|
32
ext/intl/calendar/gregoriancalendar_methods.h
Normal file
32
ext/intl/calendar/gregoriancalendar_methods.h
Normal file
@ -0,0 +1,32 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| PHP Version 5 |
|
||||
+----------------------------------------------------------------------+
|
||||
| This source file is subject to version 3.01 of the PHP license, |
|
||||
| that is bundled with this package in the file LICENSE, and is |
|
||||
| available through the world-wide-web at the following url: |
|
||||
| http://www.php.net/license/3_01.txt |
|
||||
| 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. |
|
||||
+----------------------------------------------------------------------+
|
||||
| Authors: Gustavo Lopes <cataphract@php.net> |
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
#ifndef GREORIANCALENDAR_METHODS_H
|
||||
#define GREORIANCALENDAR_METHODS_H
|
||||
|
||||
#include <php.h>
|
||||
|
||||
PHP_FUNCTION(intlgregcal_create_instance);
|
||||
|
||||
PHP_METHOD(IntlGregorianCalendar, __construct);
|
||||
|
||||
PHP_FUNCTION(intlgregcal_set_gregorian_change);
|
||||
|
||||
PHP_FUNCTION(intlgregcal_get_gregorian_change);
|
||||
|
||||
PHP_FUNCTION(intlgregcal_is_leap_year);
|
||||
|
||||
#endif
|
383
ext/intl/common/common_enum.cpp
Normal file
383
ext/intl/common/common_enum.cpp
Normal file
@ -0,0 +1,383 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| PHP Version 5 |
|
||||
+----------------------------------------------------------------------+
|
||||
| This source file is subject to version 3.01 of the PHP license, |
|
||||
| that is bundled with this package in the file LICENSE, and is |
|
||||
| available through the world-wide-web at the following url: |
|
||||
| http://www.php.net/license/3_01.txt |
|
||||
| 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. |
|
||||
+----------------------------------------------------------------------+
|
||||
| Authors: Gustavo Lopes <cataphract@php.net> |
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
// Fix build on Windows/old versions of ICU
|
||||
#include <stdio.h>
|
||||
|
||||
#include "common_enum.h"
|
||||
|
||||
extern "C" {
|
||||
#include "intl_error.h"
|
||||
#include "intl_data.h"
|
||||
#include <zend_interfaces.h>
|
||||
#include <zend_exceptions.h>
|
||||
}
|
||||
|
||||
static zend_class_entry *IntlIterator_ce_ptr;
|
||||
static zend_object_handlers IntlIterator_handlers;
|
||||
|
||||
typedef struct {
|
||||
zend_object zo;
|
||||
intl_error err;
|
||||
zend_object_iterator *iterator;
|
||||
} IntlIterator_object;
|
||||
|
||||
#define INTLITERATOR_ERROR(ii) (ii)->err
|
||||
#define INTLITERATOR_ERROR_P(ii) &(INTLITERATOR_ERROR(ii))
|
||||
|
||||
#define INTLITERATOR_ERROR_CODE(ii) INTL_ERROR_CODE(INTLITERATOR_ERROR(ii))
|
||||
#define INTLITERATOR_ERROR_CODE_P(ii) &(INTL_ERROR_CODE(INTLITERATOR_ERROR(ii)))
|
||||
|
||||
#define INTLITERATOR_METHOD_INIT_VARS INTL_METHOD_INIT_VARS(IntlIterator, ii)
|
||||
#define INTLITERATOR_METHOD_FETCH_OBJECT_NO_CHECK INTL_METHOD_FETCH_OBJECT(IntlIterator, ii)
|
||||
#define INTLITERATOR_METHOD_FETCH_OBJECT\
|
||||
object = getThis(); \
|
||||
INTLITERATOR_METHOD_FETCH_OBJECT_NO_CHECK; \
|
||||
if (ii->iterator == NULL) { \
|
||||
intl_errors_set(&ii->err, U_ILLEGAL_ARGUMENT_ERROR, "Found unconstructed IntlIterator", 0 TSRMLS_CC); \
|
||||
RETURN_FALSE; \
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
zend_object_iterator zoi;
|
||||
zval *current;
|
||||
zval *wrapping_obj;
|
||||
void (*destroy_free_it)(zend_object_iterator *iterator TSRMLS_DC);
|
||||
} zoi_with_current;
|
||||
|
||||
static void zoi_with_current_dtor(zend_object_iterator *iter TSRMLS_DC)
|
||||
{
|
||||
zoi_with_current *zoiwc = (zoi_with_current*)iter;
|
||||
|
||||
if (zoiwc->wrapping_obj) {
|
||||
/* we have to copy the pointer because zoiwc->wrapping_obj may be
|
||||
* changed midway the execution of zval_ptr_dtor() */
|
||||
zval *zwo = zoiwc->wrapping_obj;
|
||||
|
||||
/* object is still here, we can rely on it to call this again and
|
||||
* destroy this object */
|
||||
zval_ptr_dtor(&zwo);
|
||||
} else {
|
||||
/* Object not here anymore (we've been called by the object free handler)
|
||||
* Note that the iterator wrapper objects (that also depend on this
|
||||
* structure) call this function earlier, in the destruction phase, which
|
||||
* precedes the object free phase. Therefore there's no risk on this
|
||||
* function being called by the iterator wrapper destructor function and
|
||||
* not finding the memory of this iterator allocated anymore. */
|
||||
iter->funcs->invalidate_current(iter TSRMLS_CC);
|
||||
zoiwc->destroy_free_it(iter TSRMLS_CC);
|
||||
efree(iter);
|
||||
}
|
||||
}
|
||||
|
||||
static int zoi_with_current_valid(zend_object_iterator *iter TSRMLS_DC)
|
||||
{
|
||||
return ((zoi_with_current*)iter)->current != NULL ? SUCCESS : FAILURE;
|
||||
}
|
||||
|
||||
static void zoi_with_current_get_current_data(zend_object_iterator *iter, zval ***data TSRMLS_DC)
|
||||
{
|
||||
*data = &((zoi_with_current*)iter)->current;
|
||||
}
|
||||
|
||||
static void zoi_with_current_invalidate_current(zend_object_iterator *iter TSRMLS_DC)
|
||||
{
|
||||
zoi_with_current *zoi_iter = (zoi_with_current*)iter;
|
||||
if (zoi_iter->current) {
|
||||
zval_ptr_dtor(&zoi_iter->current);
|
||||
zoi_iter->current = NULL; //valid would return FAILURE now
|
||||
}
|
||||
}
|
||||
|
||||
static void string_enum_current_move_forward(zend_object_iterator *iter TSRMLS_DC)
|
||||
{
|
||||
zoi_with_current *zoi_iter = (zoi_with_current*)iter;
|
||||
INTLITERATOR_METHOD_INIT_VARS;
|
||||
|
||||
iter->funcs->invalidate_current(iter TSRMLS_CC);
|
||||
|
||||
object = zoi_iter->wrapping_obj;
|
||||
INTLITERATOR_METHOD_FETCH_OBJECT_NO_CHECK;
|
||||
|
||||
int32_t result_length;
|
||||
const char *result = ((StringEnumeration*)iter->data)->next(
|
||||
&result_length, INTLITERATOR_ERROR_CODE(ii));
|
||||
|
||||
intl_error_set_code(NULL, INTLITERATOR_ERROR_CODE(ii) TSRMLS_CC);
|
||||
if (U_FAILURE(INTLITERATOR_ERROR_CODE(ii))) {
|
||||
intl_errors_set_custom_msg(INTL_DATA_ERROR_P(ii),
|
||||
"Error fetching next iteration element", 0 TSRMLS_CC);
|
||||
} else if (result) {
|
||||
MAKE_STD_ZVAL(zoi_iter->current);
|
||||
ZVAL_STRINGL(zoi_iter->current, result, result_length, 1);
|
||||
} //else we've reached the end of the enum, nothing more is required
|
||||
}
|
||||
|
||||
static void string_enum_rewind(zend_object_iterator *iter TSRMLS_DC)
|
||||
{
|
||||
zoi_with_current *zoi_iter = (zoi_with_current*)iter;
|
||||
INTLITERATOR_METHOD_INIT_VARS;
|
||||
|
||||
if (zoi_iter->current) {
|
||||
iter->funcs->invalidate_current(iter TSRMLS_CC);
|
||||
}
|
||||
|
||||
object = zoi_iter->wrapping_obj;
|
||||
INTLITERATOR_METHOD_FETCH_OBJECT_NO_CHECK;
|
||||
|
||||
((StringEnumeration*)iter->data)->reset(INTLITERATOR_ERROR_CODE(ii));
|
||||
|
||||
intl_error_set_code(NULL, INTLITERATOR_ERROR_CODE(ii) TSRMLS_CC);
|
||||
if (U_FAILURE(INTLITERATOR_ERROR_CODE(ii))) {
|
||||
intl_errors_set_custom_msg(INTL_DATA_ERROR_P(ii),
|
||||
"Error resetting enumeration", 0 TSRMLS_CC);
|
||||
} else {
|
||||
iter->funcs->move_forward(iter TSRMLS_CC);
|
||||
}
|
||||
}
|
||||
|
||||
static void string_enum_destroy_free_it(zend_object_iterator *iter TSRMLS_DC)
|
||||
{
|
||||
delete (StringEnumeration*)iter->data;
|
||||
}
|
||||
|
||||
static zend_object_iterator_funcs string_enum_object_iterator_funcs = {
|
||||
zoi_with_current_dtor,
|
||||
zoi_with_current_valid,
|
||||
zoi_with_current_get_current_data,
|
||||
NULL,
|
||||
string_enum_current_move_forward,
|
||||
string_enum_rewind,
|
||||
zoi_with_current_invalidate_current
|
||||
};
|
||||
|
||||
U_CFUNC void IntlIterator_from_StringEnumeration(StringEnumeration *se, zval *object TSRMLS_DC)
|
||||
{
|
||||
IntlIterator_object *ii;
|
||||
object_init_ex(object, IntlIterator_ce_ptr);
|
||||
ii = (IntlIterator_object*)zend_object_store_get_object(object TSRMLS_CC);
|
||||
ii->iterator = (zend_object_iterator*)emalloc(sizeof(zoi_with_current));
|
||||
ii->iterator->data = (void*)se;
|
||||
ii->iterator->funcs = &string_enum_object_iterator_funcs;
|
||||
ii->iterator->index = 0;
|
||||
((zoi_with_current*)ii->iterator)->destroy_free_it = string_enum_destroy_free_it;
|
||||
((zoi_with_current*)ii->iterator)->wrapping_obj = object;
|
||||
((zoi_with_current*)ii->iterator)->current = NULL;
|
||||
}
|
||||
|
||||
static void IntlIterator_objects_free(zend_object *object TSRMLS_DC)
|
||||
{
|
||||
IntlIterator_object *ii = (IntlIterator_object*) object;
|
||||
|
||||
if (ii->iterator) {
|
||||
zval **wrapping_objp = &((zoi_with_current*)ii->iterator)->wrapping_obj;
|
||||
*wrapping_objp = NULL;
|
||||
ii->iterator->funcs->dtor(ii->iterator TSRMLS_CC);
|
||||
}
|
||||
intl_error_reset(INTLITERATOR_ERROR_P(ii) TSRMLS_CC);
|
||||
|
||||
zend_object_std_dtor(&ii->zo TSRMLS_CC);
|
||||
|
||||
efree(ii);
|
||||
}
|
||||
|
||||
static zend_object_iterator *IntlIterator_get_iterator(
|
||||
zend_class_entry *ce, zval *object, int by_ref TSRMLS_DC)
|
||||
{
|
||||
if (by_ref) {
|
||||
zend_throw_exception(NULL,
|
||||
"Iteration by reference is not supported", 0 TSRMLS_CC);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
IntlIterator_object *ii = (IntlIterator_object*)
|
||||
zend_object_store_get_object(object TSRMLS_CC);
|
||||
|
||||
if (ii->iterator == NULL) {
|
||||
zend_throw_exception(NULL,
|
||||
"The IntlIterator is not properly constructed", 0 TSRMLS_CC);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
zval_add_ref(&object);
|
||||
|
||||
return ii->iterator;
|
||||
}
|
||||
|
||||
static zend_object_value IntlIterator_object_create(zend_class_entry *ce TSRMLS_DC)
|
||||
{
|
||||
zend_object_value retval;
|
||||
IntlIterator_object *intern;
|
||||
|
||||
intern = (IntlIterator_object*)ecalloc(1, sizeof(IntlIterator_object));
|
||||
|
||||
zend_object_std_init(&intern->zo, ce TSRMLS_CC);
|
||||
#if PHP_VERSION_ID < 50399
|
||||
zend_hash_copy(intern->zo.properties, &(ce->default_properties),
|
||||
(copy_ctor_func_t) zval_add_ref, NULL, sizeof(zval*));
|
||||
#else
|
||||
object_properties_init((zend_object*) intern, ce);
|
||||
#endif
|
||||
intl_error_init(INTLITERATOR_ERROR_P(intern) TSRMLS_CC);
|
||||
intern->iterator = NULL;
|
||||
|
||||
retval.handle = zend_objects_store_put(
|
||||
intern,
|
||||
(zend_objects_store_dtor_t)zend_objects_destroy_object,
|
||||
(zend_objects_free_object_storage_t)IntlIterator_objects_free,
|
||||
NULL TSRMLS_CC);
|
||||
|
||||
retval.handlers = &IntlIterator_handlers;
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
static PHP_METHOD(IntlIterator, current)
|
||||
{
|
||||
zval **data;
|
||||
INTLITERATOR_METHOD_INIT_VARS;
|
||||
|
||||
if (zend_parse_parameters_none() == FAILURE) {
|
||||
intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
|
||||
"IntlIterator::current: bad arguments", 0 TSRMLS_CC);
|
||||
return;
|
||||
}
|
||||
|
||||
INTLITERATOR_METHOD_FETCH_OBJECT;
|
||||
ii->iterator->funcs->get_current_data(ii->iterator, &data TSRMLS_CC);
|
||||
if (data && *data) {
|
||||
RETURN_ZVAL(*data, 1, 0);
|
||||
}
|
||||
}
|
||||
|
||||
static PHP_METHOD(IntlIterator, key)
|
||||
{
|
||||
INTLITERATOR_METHOD_INIT_VARS;
|
||||
|
||||
if (zend_parse_parameters_none() == FAILURE) {
|
||||
intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
|
||||
"IntlIterator::key: bad arguments", 0 TSRMLS_CC);
|
||||
return;
|
||||
}
|
||||
|
||||
INTLITERATOR_METHOD_FETCH_OBJECT;
|
||||
|
||||
if (ii->iterator->funcs->get_current_key) {
|
||||
char *str_key;
|
||||
uint str_key_len;
|
||||
ulong int_key;
|
||||
|
||||
switch (ii->iterator->funcs->get_current_key(
|
||||
ii->iterator, &str_key, &str_key_len, &int_key TSRMLS_CC)) {
|
||||
case HASH_KEY_IS_LONG:
|
||||
RETURN_LONG(int_key);
|
||||
break;
|
||||
case HASH_KEY_IS_STRING:
|
||||
RETURN_STRINGL(str_key, str_key_len-1, 0);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
RETURN_LONG(ii->iterator->index);
|
||||
}
|
||||
}
|
||||
|
||||
static PHP_METHOD(IntlIterator, next)
|
||||
{
|
||||
INTLITERATOR_METHOD_INIT_VARS;
|
||||
|
||||
if (zend_parse_parameters_none() == FAILURE) {
|
||||
intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
|
||||
"IntlIterator::next: bad arguments", 0 TSRMLS_CC);
|
||||
return;
|
||||
}
|
||||
|
||||
INTLITERATOR_METHOD_FETCH_OBJECT;
|
||||
ii->iterator->funcs->move_forward(ii->iterator TSRMLS_CC);
|
||||
/* foreach also advances the index after the last iteration,
|
||||
* so I see no problem in incrementing the index here unconditionally */
|
||||
ii->iterator->index++;
|
||||
}
|
||||
|
||||
static PHP_METHOD(IntlIterator, rewind)
|
||||
{
|
||||
INTLITERATOR_METHOD_INIT_VARS;
|
||||
|
||||
if (zend_parse_parameters_none() == FAILURE) {
|
||||
intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
|
||||
"IntlIterator::rewind: bad arguments", 0 TSRMLS_CC);
|
||||
return;
|
||||
}
|
||||
|
||||
INTLITERATOR_METHOD_FETCH_OBJECT;
|
||||
if (ii->iterator->funcs->rewind) {
|
||||
ii->iterator->funcs->rewind(ii->iterator TSRMLS_CC);
|
||||
} else {
|
||||
intl_error_set(NULL, U_UNSUPPORTED_ERROR,
|
||||
"IntlIterator::rewind: rewind not supported", 0 TSRMLS_CC);
|
||||
}
|
||||
}
|
||||
|
||||
static PHP_METHOD(IntlIterator, valid)
|
||||
{
|
||||
INTLITERATOR_METHOD_INIT_VARS;
|
||||
|
||||
if (zend_parse_parameters_none() == FAILURE) {
|
||||
intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
|
||||
"IntlIterator::valid: bad arguments", 0 TSRMLS_CC);
|
||||
return;
|
||||
}
|
||||
|
||||
INTLITERATOR_METHOD_FETCH_OBJECT;
|
||||
RETURN_BOOL(ii->iterator->funcs->valid(ii->iterator TSRMLS_CC) == SUCCESS);
|
||||
}
|
||||
|
||||
ZEND_BEGIN_ARG_INFO_EX(ainfo_se_void, 0, 0, 0)
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
static zend_function_entry IntlIterator_class_functions[] = {
|
||||
PHP_ME(IntlIterator, current, ainfo_se_void, ZEND_ACC_PUBLIC)
|
||||
PHP_ME(IntlIterator, key, ainfo_se_void, ZEND_ACC_PUBLIC)
|
||||
PHP_ME(IntlIterator, next, ainfo_se_void, ZEND_ACC_PUBLIC)
|
||||
PHP_ME(IntlIterator, rewind, ainfo_se_void, ZEND_ACC_PUBLIC)
|
||||
PHP_ME(IntlIterator, valid, ainfo_se_void, ZEND_ACC_PUBLIC)
|
||||
PHP_FE_END
|
||||
};
|
||||
|
||||
|
||||
/* {{{ intl_register_IntlIterator_class
|
||||
* Initialize 'IntlIterator' class
|
||||
*/
|
||||
U_CFUNC void intl_register_IntlIterator_class(TSRMLS_D)
|
||||
{
|
||||
zend_class_entry ce;
|
||||
|
||||
/* Create and register 'IntlIterator' class. */
|
||||
INIT_CLASS_ENTRY(ce, "IntlIterator", IntlIterator_class_functions);
|
||||
ce.create_object = IntlIterator_object_create;
|
||||
IntlIterator_ce_ptr = zend_register_internal_class(&ce TSRMLS_CC);
|
||||
IntlIterator_ce_ptr->get_iterator = IntlIterator_get_iterator;
|
||||
zend_class_implements(IntlIterator_ce_ptr TSRMLS_CC, 1,
|
||||
zend_ce_iterator);
|
||||
|
||||
memcpy(&IntlIterator_handlers, zend_get_std_object_handlers(),
|
||||
sizeof IntlIterator_handlers);
|
||||
IntlIterator_handlers.clone_obj = NULL;
|
||||
|
||||
}
|
38
ext/intl/common/common_enum.h
Normal file
38
ext/intl/common/common_enum.h
Normal file
@ -0,0 +1,38 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| PHP Version 5 |
|
||||
+----------------------------------------------------------------------+
|
||||
| This source file is subject to version 3.01 of the PHP license, |
|
||||
| that is bundled with this package in the file LICENSE, and is |
|
||||
| available through the world-wide-web at the following url: |
|
||||
| http://www.php.net/license/3_01.txt |
|
||||
| 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. |
|
||||
+----------------------------------------------------------------------+
|
||||
| Authors: Vadim Savchuk <vsavchuk@productengine.com> |
|
||||
| Dmitry Lakhtyuk <dlakhtyuk@productengine.com> |
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
#ifndef INTL_COMMON_ENUM_H
|
||||
#define INTL_COMMON_ENUM_H
|
||||
|
||||
#include <unicode/umachine.h>
|
||||
#ifdef __cplusplus
|
||||
#include <unicode/strenum.h>
|
||||
extern "C" {
|
||||
#include <math.h>
|
||||
#endif
|
||||
#include <php.h>
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
U_CFUNC void IntlIterator_from_StringEnumeration(StringEnumeration *se, zval *object TSRMLS_DC);
|
||||
#endif
|
||||
|
||||
U_CFUNC void intl_register_IntlIterator_class(TSRMLS_D);
|
||||
|
||||
#endif // INTL_COMMON_ENUM_H
|
@ -20,6 +20,7 @@ if test "$PHP_INTL" != "no"; then
|
||||
PHP_NEW_EXTENSION(intl, php_intl.c \
|
||||
intl_error.c \
|
||||
intl_convert.c \
|
||||
intl_convertcpp.cpp \
|
||||
collator/collator.c \
|
||||
collator/collator_class.c \
|
||||
collator/collator_sort.c \
|
||||
@ -31,6 +32,7 @@ if test "$PHP_INTL" != "no"; then
|
||||
collator/collator_is_numeric.c \
|
||||
collator/collator_error.c \
|
||||
common/common_error.c \
|
||||
common/common_enum.cpp \
|
||||
formatter/formatter.c \
|
||||
formatter/formatter_main.c \
|
||||
formatter/formatter_class.c \
|
||||
@ -65,8 +67,13 @@ if test "$PHP_INTL" != "no"; then
|
||||
transliterator/transliterator.c \
|
||||
transliterator/transliterator_class.c \
|
||||
transliterator/transliterator_methods.c \
|
||||
timezone/timezone_class.cpp \
|
||||
timezone/timezone_methods.cpp \
|
||||
calendar/calendar_class.cpp \
|
||||
calendar/calendar_methods.cpp \
|
||||
calendar/gregoriancalendar_methods.cpp \
|
||||
idn/idn.c \
|
||||
$icu_spoof_src, $ext_shared,,$ICU_INCS)
|
||||
$icu_spoof_src, $ext_shared,,$ICU_INCS -Wno-write-strings)
|
||||
PHP_ADD_BUILD_DIR($ext_builddir/collator)
|
||||
PHP_ADD_BUILD_DIR($ext_builddir/common)
|
||||
PHP_ADD_BUILD_DIR($ext_builddir/formatter)
|
||||
@ -77,6 +84,8 @@ if test "$PHP_INTL" != "no"; then
|
||||
PHP_ADD_BUILD_DIR($ext_builddir/grapheme)
|
||||
PHP_ADD_BUILD_DIR($ext_builddir/resourcebundle)
|
||||
PHP_ADD_BUILD_DIR($ext_builddir/transliterator)
|
||||
PHP_ADD_BUILD_DIR($ext_builddir/timezone)
|
||||
PHP_ADD_BUILD_DIR($ext_builddir/calendar)
|
||||
PHP_ADD_BUILD_DIR($ext_builddir/idn)
|
||||
PHP_ADD_BUILD_DIR($ext_builddir/spoofchecker)
|
||||
fi
|
||||
|
@ -7,7 +7,7 @@ if (PHP_INTL != "no") {
|
||||
if (CHECK_LIB("icuuc.lib", "intl", PHP_INTL) &&
|
||||
CHECK_HEADER_ADD_INCLUDE("unicode/utf.h", "CFLAGS_INTL")) {
|
||||
// always build as shared - zend_strtod.c/ICU type conflict
|
||||
EXTENSION("intl", "php_intl.c intl_convert.c intl_error.c ", true,
|
||||
EXTENSION("intl", "php_intl.c intl_convert.c intl_convertcpp.cpp intl_error.c ", true,
|
||||
"/I \"" + configure_module_dirname + "\"");
|
||||
ADD_SOURCES(configure_module_dirname + "/collator", "\
|
||||
collator.c \
|
||||
@ -23,6 +23,7 @@ if (PHP_INTL != "no") {
|
||||
", "intl");
|
||||
ADD_SOURCES(configure_module_dirname + "/common", "\
|
||||
common_error.c \
|
||||
common_enum.cpp \
|
||||
", "intl");
|
||||
ADD_SOURCES(configure_module_dirname + "/formatter", "\
|
||||
formatter.c \
|
||||
@ -87,6 +88,18 @@ if (PHP_INTL != "no") {
|
||||
transliterator_class.c \
|
||||
transliterator_methods.c",
|
||||
"intl");
|
||||
|
||||
ADD_SOURCES(configure_module_dirname + "/timezone", "\
|
||||
timezone_class.cpp \
|
||||
timezone_methods.cpp",
|
||||
"intl");
|
||||
|
||||
ADD_SOURCES(configure_module_dirname + "/calendar", "\
|
||||
calendar_methods.cpp \
|
||||
gregoriancalendar_methods.cpp \
|
||||
calendar_class.cpp",
|
||||
"intl");
|
||||
|
||||
ADD_FLAG("LIBS_INTL", "icudt.lib icuin.lib icuio.lib icule.lib iculx.lib");
|
||||
AC_DEFINE("HAVE_INTL", 1, "Internationalization support enabled");
|
||||
} else {
|
||||
|
83
ext/intl/intl_convertcpp.cpp
Normal file
83
ext/intl/intl_convertcpp.cpp
Normal file
@ -0,0 +1,83 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| PHP Version 5 |
|
||||
+----------------------------------------------------------------------+
|
||||
| This source file is subject to version 3.01 of the PHP license, |
|
||||
| that is bundled with this package in the file LICENSE, and is |
|
||||
| available through the world-wide-web at the following url: |
|
||||
| http://www.php.net/license/3_01.txt |
|
||||
| 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. |
|
||||
+----------------------------------------------------------------------+
|
||||
| Authors: Gustavo Lopes <cataphract@php.net> |
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/* $Id$ */
|
||||
|
||||
//Fixes the build on old versions of ICU with Windows
|
||||
#include <stdio.h>
|
||||
|
||||
#include "intl_convertcpp.h"
|
||||
#include <unicode/ustring.h>
|
||||
extern "C" {
|
||||
#include <php.h>
|
||||
}
|
||||
|
||||
/* {{{ intl_stringFromChar */
|
||||
int intl_stringFromChar(UnicodeString &ret, char *str, int32_t str_len, UErrorCode *status)
|
||||
{
|
||||
//the number of UTF-16 code units is not larger than that of UTF-8 code
|
||||
//units, + 1 for the terminator
|
||||
int32_t capacity = str_len + 1;
|
||||
|
||||
//no check necessary -- if NULL will fail ahead
|
||||
UChar *utf16 = ret.getBuffer(capacity);
|
||||
int32_t utf16_len = 0;
|
||||
*status = U_ZERO_ERROR;
|
||||
u_strFromUTF8WithSub(utf16, ret.getCapacity(), &utf16_len,
|
||||
str, str_len, U_SENTINEL /* no substitution */, NULL,
|
||||
status);
|
||||
ret.releaseBuffer(utf16_len);
|
||||
if (U_FAILURE(*status)) {
|
||||
ret.setToBogus();
|
||||
return FAILURE;
|
||||
}
|
||||
return SUCCESS;
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ intl_charFromString */
|
||||
int intl_charFromString(const UnicodeString &from, char **res, int *res_len, UErrorCode *status)
|
||||
{
|
||||
//the number of UTF-8 code units is not larger than that of UTF-16 code
|
||||
//units * 3 + 1 for the terminator
|
||||
int32_t capacity = from.length() * 3 + 1;
|
||||
|
||||
if (from.isEmpty()) {
|
||||
*res = (char*)emalloc(1);
|
||||
**res = '\0';
|
||||
*res_len = 0;
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
*res = (char*)emalloc(capacity);
|
||||
*res_len = 0; //tbd
|
||||
|
||||
const UChar *utf16buf = from.getBuffer();
|
||||
int32_t actual_len;
|
||||
u_strToUTF8WithSub(*res, capacity - 1, &actual_len, utf16buf, from.length(),
|
||||
U_SENTINEL, NULL, status);
|
||||
|
||||
if (U_FAILURE(*status)) {
|
||||
efree(*res);
|
||||
*res = NULL;
|
||||
return FAILURE;
|
||||
}
|
||||
(*res)[actual_len] = '\0';
|
||||
*res_len = (int)actual_len;
|
||||
|
||||
return SUCCESS;
|
||||
}
|
||||
/* }}} */
|
32
ext/intl/intl_convertcpp.h
Normal file
32
ext/intl/intl_convertcpp.h
Normal file
@ -0,0 +1,32 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| PHP Version 5 |
|
||||
+----------------------------------------------------------------------+
|
||||
| This source file is subject to version 3.01 of the PHP license, |
|
||||
| that is bundled with this package in the file LICENSE, and is |
|
||||
| available through the world-wide-web at the following url: |
|
||||
| http://www.php.net/license/3_01.txt |
|
||||
| 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. |
|
||||
+----------------------------------------------------------------------+
|
||||
| Authors: Gustavo Lopes <cataphract@php.net> |
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/* $Id$ */
|
||||
|
||||
#ifndef INTL_CONVERTCPP_H
|
||||
#define INTL_CONVERTCPP_H
|
||||
|
||||
#ifndef __cplusplus
|
||||
#error Should be included only in C++ Files
|
||||
#endif
|
||||
|
||||
#include <unicode/unistr.h>
|
||||
|
||||
int intl_stringFromChar(UnicodeString &ret, char *str, int32_t str_len, UErrorCode *status);
|
||||
|
||||
int intl_charFromString(const UnicodeString &from, char **res, int *res_len, UErrorCode *status);
|
||||
|
||||
#endif /* INTL_CONVERTCPP_H */
|
@ -22,6 +22,8 @@
|
||||
#include <php.h>
|
||||
|
||||
void locale_register_constants( INIT_FUNC_ARGS );
|
||||
|
||||
const char *intl_locale_get_default( TSRMLS_D );
|
||||
|
||||
#define OPTION_DEFAULT NULL
|
||||
#define LOC_LANG_TAG "language"
|
||||
|
@ -201,6 +201,14 @@ static int getSingletonPos(char* str)
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
const char *intl_locale_get_default( TSRMLS_D )
|
||||
{
|
||||
if( INTL_G(default_locale) == NULL ) {
|
||||
return uloc_getDefault();
|
||||
}
|
||||
return INTL_G(default_locale);
|
||||
}
|
||||
|
||||
/* {{{ proto static string Locale::getDefault( )
|
||||
Get default locale */
|
||||
/* }}} */
|
||||
@ -208,10 +216,7 @@ static int getSingletonPos(char* str)
|
||||
Get default locale */
|
||||
PHP_NAMED_FUNCTION(zif_locale_get_default)
|
||||
{
|
||||
if( INTL_G(default_locale) == NULL ) {
|
||||
INTL_G(default_locale) = pestrdup( uloc_getDefault(), 1);
|
||||
}
|
||||
RETURN_STRING( INTL_G(default_locale), TRUE );
|
||||
RETURN_STRING( intl_locale_get_default( TSRMLS_C ), TRUE );
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
|
@ -18,6 +18,9 @@
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
// Fix build on Windows / old versions of ICU
|
||||
#include <stdio.h>
|
||||
|
||||
#include <math.h>
|
||||
#include <unicode/msgfmt.h>
|
||||
#include <unicode/chariter.h>
|
||||
|
@ -68,6 +68,13 @@
|
||||
#include "transliterator/transliterator_class.h"
|
||||
#include "transliterator/transliterator_methods.h"
|
||||
|
||||
#include "timezone/timezone_class.h"
|
||||
#include "timezone/timezone_methods.h"
|
||||
|
||||
#include "calendar/calendar_class.h"
|
||||
#include "calendar/calendar_methods.h"
|
||||
#include "calendar/gregoriancalendar_methods.h"
|
||||
|
||||
#include "idn/idn.h"
|
||||
|
||||
#if U_ICU_VERSION_MAJOR_NUM > 3 && U_ICU_VERSION_MINOR_NUM >=2
|
||||
@ -79,6 +86,7 @@
|
||||
|
||||
#include "msgformat/msgformat.h"
|
||||
#include "common/common_error.h"
|
||||
#include "common/common_enum.h"
|
||||
|
||||
#include <unicode/uloc.h>
|
||||
#include <ext/standard/info.h>
|
||||
@ -402,6 +410,181 @@ ZEND_BEGIN_ARG_INFO_EX( arginfo_transliterator_error, 0, 0, 1 )
|
||||
ZEND_ARG_OBJ_INFO( 0, trans, Transliterator, 0 )
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
ZEND_BEGIN_ARG_INFO_EX( arginfo_tz_idarg_static, 0, 0, 1 )
|
||||
ZEND_ARG_INFO( 0, zoneId )
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
ZEND_BEGIN_ARG_INFO_EX( arginfo_tz_create_enumeration, 0, 0, 0 )
|
||||
ZEND_ARG_INFO( 0, countryOrRawOffset )
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
ZEND_BEGIN_ARG_INFO_EX( arginfo_tz_count_equivalent_ids, 0, 0, 1 )
|
||||
ZEND_ARG_INFO( 0, zoneId )
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
ZEND_BEGIN_ARG_INFO_EX( arginfo_tz_create_time_zone_id_enumeration, 0, 0, 1 )
|
||||
ZEND_ARG_INFO( 0, zoneType )
|
||||
ZEND_ARG_INFO( 0, region )
|
||||
ZEND_ARG_INFO( 0, rawOffset )
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
ZEND_BEGIN_ARG_INFO_EX( arginfo_tz_get_canonical_id, 0, 0, 1 )
|
||||
ZEND_ARG_INFO( 0, zoneId )
|
||||
ZEND_ARG_INFO( 1, isSystemID )
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
ZEND_BEGIN_ARG_INFO_EX( arginfo_tz_get_equivalent_id, 0, 0, 2 )
|
||||
ZEND_ARG_INFO( 0, zoneId )
|
||||
ZEND_ARG_INFO( 0, index )
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
ZEND_BEGIN_ARG_INFO_EX( arginfo_tz_get_offset, 0, 0, 5 )
|
||||
ZEND_ARG_OBJ_INFO( 0, timeZone, IntlTimeZone, 0 )
|
||||
ZEND_ARG_INFO( 0, date )
|
||||
ZEND_ARG_INFO( 0, local )
|
||||
ZEND_ARG_INFO( 1, rawOffset )
|
||||
ZEND_ARG_INFO( 1, dstOffset )
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
ZEND_BEGIN_ARG_INFO_EX( arginfo_tz_has_same_rules, 0, 0, 1 )
|
||||
ZEND_ARG_OBJ_INFO( 0, timeZone, IntlTimeZone, 0 )
|
||||
ZEND_ARG_OBJ_INFO( 0, otherTimeZone, IntlTimeZone, 0 )
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
ZEND_BEGIN_ARG_INFO_EX( arginfo_tz_get_display_name, 0, 0, 1 )
|
||||
ZEND_ARG_OBJ_INFO( 0, timeZone, IntlTimeZone, 0 )
|
||||
ZEND_ARG_INFO( 0, isDaylight )
|
||||
ZEND_ARG_INFO( 0, style )
|
||||
ZEND_ARG_INFO( 0, locale )
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
ZEND_BEGIN_ARG_INFO_EX( arginfo_tz_only_tz, 0, 0, 1 )
|
||||
ZEND_ARG_OBJ_INFO( 0, timeZone, IntlTimeZone, 0 )
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
ZEND_BEGIN_ARG_INFO_EX( arginfo_tz_void, 0, 0, 0 )
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
ZEND_BEGIN_ARG_INFO_EX( ainfo_cal_create_instance, 0, 0, 0 )
|
||||
ZEND_ARG_INFO( 0, timeZone )
|
||||
ZEND_ARG_INFO( 0, locale )
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
ZEND_BEGIN_ARG_INFO_EX( ainfo_cal_only_cal, 0, 0, 1 )
|
||||
ZEND_ARG_OBJ_INFO( 0, calendar, IntlCalendar, 0 )
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
ZEND_BEGIN_ARG_INFO_EX( ainfo_cal_void, 0, 0, 0 )
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
ZEND_BEGIN_ARG_INFO_EX( ainfo_cal_field, 0, 0, 2 )
|
||||
ZEND_ARG_OBJ_INFO( 0, calendar, IntlCalendar, 0 )
|
||||
ZEND_ARG_INFO( 0, field )
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
ZEND_BEGIN_ARG_INFO_EX( ainfo_cal_dow, 0, 0, 2 )
|
||||
ZEND_ARG_OBJ_INFO( 0, calendar, IntlCalendar, 0 )
|
||||
ZEND_ARG_INFO( 0, dayOfWeek )
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
ZEND_BEGIN_ARG_INFO_EX( ainfo_cal_other_cal, 0, 0, 2 )
|
||||
ZEND_ARG_OBJ_INFO( 0, calendar, IntlCalendar, 0 )
|
||||
ZEND_ARG_OBJ_INFO( 0, otherCalendar, IntlCalendar, 0 )
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
ZEND_BEGIN_ARG_INFO_EX( ainfo_cal_date, 0, 0, 2 )
|
||||
ZEND_ARG_OBJ_INFO( 0, calendar, IntlCalendar, 0 )
|
||||
ZEND_ARG_INFO( 0, date )
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
ZEND_BEGIN_ARG_INFO_EX( ainfo_cal_date_optional, 0, 0, 1 )
|
||||
ZEND_ARG_OBJ_INFO( 0, calendar, IntlCalendar, 0 )
|
||||
ZEND_ARG_INFO( 0, date )
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
ZEND_BEGIN_ARG_INFO_EX( ainfo_cal_get_keyword_values_for_locale, 0, 0, 3)
|
||||
ZEND_ARG_INFO( 0, key )
|
||||
ZEND_ARG_INFO( 0, locale )
|
||||
ZEND_ARG_INFO( 0, commonlyUsed )
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
ZEND_BEGIN_ARG_INFO_EX( ainfo_cal_add, 0, 0, 3 )
|
||||
ZEND_ARG_OBJ_INFO( 0, calendar, IntlCalendar, 0 )
|
||||
ZEND_ARG_INFO( 0, field )
|
||||
ZEND_ARG_INFO( 0, amount )
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
ZEND_BEGIN_ARG_INFO_EX( ainfo_cal_set_time_zone, 0, 0, 2 )
|
||||
ZEND_ARG_OBJ_INFO( 0, calendar, IntlCalendar, 0 )
|
||||
ZEND_ARG_OBJ_INFO( 0, timeZone, IntlTimeZone, 1 )
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
ZEND_BEGIN_ARG_INFO_EX( ainfo_cal_set, 0, 0, 3 )
|
||||
ZEND_ARG_OBJ_INFO( 0, calendar, IntlCalendar, 0 )
|
||||
ZEND_ARG_INFO( 0, fieldOrYear )
|
||||
ZEND_ARG_INFO( 0, valueOrMonth )
|
||||
ZEND_ARG_INFO( 0, dayOfMonth )
|
||||
ZEND_ARG_INFO( 0, hour )
|
||||
ZEND_ARG_INFO( 0, minute )
|
||||
ZEND_ARG_INFO( 0, second )
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
ZEND_BEGIN_ARG_INFO_EX( ainfo_cal_roll, 0, 0, 2 )
|
||||
ZEND_ARG_OBJ_INFO( 0, calendar, IntlCalendar, 0 )
|
||||
ZEND_ARG_INFO( 0, field )
|
||||
ZEND_ARG_INFO( 0, amountOrUpOrDown )
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
ZEND_BEGIN_ARG_INFO_EX( ainfo_cal_clear, 0, 0, 1 )
|
||||
ZEND_ARG_OBJ_INFO( 0, calendar, IntlCalendar, 0 )
|
||||
ZEND_ARG_INFO( 0, field )
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
ZEND_BEGIN_ARG_INFO_EX( ainfo_cal_field_difference, 0, 0, 3 )
|
||||
ZEND_ARG_OBJ_INFO( 0, calendar, IntlCalendar, 0 )
|
||||
ZEND_ARG_INFO( 0, when )
|
||||
ZEND_ARG_INFO( 0, field )
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
ZEND_BEGIN_ARG_INFO_EX( ainfo_cal_get_locale, 0, 0, 2 )
|
||||
ZEND_ARG_OBJ_INFO( 0, calendar, IntlCalendar, 0 )
|
||||
ZEND_ARG_INFO( 0, localeType )
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
ZEND_BEGIN_ARG_INFO_EX( ainfo_cal_set_lenient, 0, 0, 2 )
|
||||
ZEND_ARG_OBJ_INFO( 0, calendar, IntlCalendar, 0 )
|
||||
ZEND_ARG_INFO( 0, isLenient )
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
ZEND_BEGIN_ARG_INFO_EX( ainfo_cal_wall_time_option, 0, 0, 2 )
|
||||
ZEND_ARG_OBJ_INFO( 0, calendar, IntlCalendar, 0 )
|
||||
ZEND_ARG_INFO( 0, wallTimeOption )
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
/* Gregorian Calendar */
|
||||
ZEND_BEGIN_ARG_INFO_EX( ainfo_gregcal_create_instance, 0, 0, 0 )
|
||||
ZEND_ARG_INFO(0, timeZoneOrYear)
|
||||
ZEND_ARG_INFO(0, localeOrMonth)
|
||||
ZEND_ARG_INFO(0, dayOfMonth)
|
||||
ZEND_ARG_INFO(0, hour)
|
||||
ZEND_ARG_INFO(0, minute)
|
||||
ZEND_ARG_INFO(0, second)
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
ZEND_BEGIN_ARG_INFO_EX( ainfo_gregcal_is_leap_year, 0, 0, 2 )
|
||||
ZEND_ARG_OBJ_INFO( 0, calendar, IntlGregorianCalendar, 0 )
|
||||
ZEND_ARG_INFO( 0, year )
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
ZEND_BEGIN_ARG_INFO_EX( ainfo_gregcal_only_gregcal, 0, 0, 1 )
|
||||
ZEND_ARG_OBJ_INFO( 0, calendar, IntlGregorianCalendar, 0 )
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
ZEND_BEGIN_ARG_INFO_EX( ainfo_gregcal_set_gregorian_change, 0, 0, 2 )
|
||||
ZEND_ARG_OBJ_INFO( 0, calendar, IntlGregorianCalendar, 0 )
|
||||
ZEND_ARG_INFO( 0, date )
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
/* }}} */
|
||||
|
||||
/* {{{ intl_functions
|
||||
@ -530,6 +713,92 @@ zend_function_entry intl_functions[] = {
|
||||
PHP_FE( transliterator_get_error_code, arginfo_transliterator_error )
|
||||
PHP_FE( transliterator_get_error_message, arginfo_transliterator_error )
|
||||
|
||||
/* TimeZone functions */
|
||||
PHP_FE( intltz_create_time_zone, arginfo_tz_idarg_static )
|
||||
PHP_FE( intltz_create_default, arginfo_tz_void )
|
||||
PHP_FE( intltz_get_id, arginfo_tz_only_tz )
|
||||
PHP_FE( intltz_get_gmt, arginfo_tz_void )
|
||||
#if U_ICU_VERSION_MAJOR_NUM >= 49
|
||||
PHP_FE( intltz_get_unknown, arginfo_tz_void )
|
||||
#endif
|
||||
PHP_FE( intltz_create_enumeration, arginfo_tz_create_enumeration )
|
||||
PHP_FE( intltz_count_equivalent_ids, arginfo_tz_idarg_static )
|
||||
#if U_ICU_VERSION_MAJOR_NUM * 10 + U_ICU_VERSION_MINOR_NUM >= 48
|
||||
PHP_FE( intltz_create_time_zone_id_enumeration, arginfo_tz_create_time_zone_id_enumeration )
|
||||
#endif
|
||||
PHP_FE( intltz_get_canonical_id, arginfo_tz_get_canonical_id )
|
||||
#if U_ICU_VERSION_MAJOR_NUM * 10 + U_ICU_VERSION_MINOR_NUM >= 48
|
||||
PHP_FE( intltz_get_region, arginfo_tz_idarg_static )
|
||||
#endif
|
||||
PHP_FE( intltz_get_tz_data_version, arginfo_tz_void )
|
||||
PHP_FE( intltz_get_equivalent_id, arginfo_tz_get_equivalent_id )
|
||||
PHP_FE( intltz_use_daylight_time, arginfo_tz_only_tz )
|
||||
PHP_FE( intltz_get_offset, arginfo_tz_get_offset )
|
||||
PHP_FE( intltz_get_raw_offset, arginfo_tz_only_tz )
|
||||
PHP_FE( intltz_has_same_rules, arginfo_tz_has_same_rules )
|
||||
PHP_FE( intltz_get_display_name, arginfo_tz_get_display_name )
|
||||
PHP_FE( intltz_get_dst_savings, arginfo_tz_only_tz )
|
||||
PHP_FE( intltz_get_error_code, arginfo_tz_only_tz )
|
||||
PHP_FE( intltz_get_error_message, arginfo_tz_only_tz )
|
||||
|
||||
PHP_FE( intlcal_create_instance, ainfo_cal_create_instance )
|
||||
#if U_ICU_VERSION_MAJOR_NUM * 10 + U_ICU_VERSION_MINOR_NUM >= 42
|
||||
PHP_FE( intlcal_get_keyword_values_for_locale, ainfo_cal_get_keyword_values_for_locale )
|
||||
#endif
|
||||
PHP_FE( intlcal_get_now, ainfo_cal_void )
|
||||
PHP_FE( intlcal_get_available_locales, ainfo_cal_void )
|
||||
PHP_FE( intlcal_get, ainfo_cal_field )
|
||||
PHP_FE( intlcal_get_time, ainfo_cal_only_cal )
|
||||
PHP_FE( intlcal_set_time, ainfo_cal_date )
|
||||
PHP_FE( intlcal_add, ainfo_cal_add )
|
||||
PHP_FE( intlcal_set_time_zone, ainfo_cal_set_time_zone )
|
||||
PHP_FE( intlcal_after, ainfo_cal_other_cal )
|
||||
PHP_FE( intlcal_before, ainfo_cal_other_cal )
|
||||
PHP_FE( intlcal_set, ainfo_cal_set )
|
||||
PHP_FE( intlcal_roll, ainfo_cal_roll )
|
||||
PHP_FE( intlcal_clear, ainfo_cal_clear )
|
||||
PHP_FE( intlcal_field_difference, ainfo_cal_field_difference )
|
||||
PHP_FE( intlcal_get_actual_maximum, ainfo_cal_field )
|
||||
PHP_FE( intlcal_get_actual_minimum, ainfo_cal_field )
|
||||
#if U_ICU_VERSION_MAJOR_NUM * 10 + U_ICU_VERSION_MINOR_NUM >= 44
|
||||
PHP_FE( intlcal_get_day_of_week_type, ainfo_cal_dow )
|
||||
#endif
|
||||
PHP_FE( intlcal_get_first_day_of_week, ainfo_cal_only_cal )
|
||||
PHP_FE( intlcal_get_greatest_minimum, ainfo_cal_field )
|
||||
PHP_FE( intlcal_get_least_maximum, ainfo_cal_field )
|
||||
PHP_FE( intlcal_get_locale, ainfo_cal_get_locale )
|
||||
PHP_FE( intlcal_get_maximum, ainfo_cal_field )
|
||||
PHP_FE( intlcal_get_minimal_days_in_first_week, ainfo_cal_only_cal )
|
||||
PHP_FE( intlcal_get_minimum, ainfo_cal_field )
|
||||
PHP_FE( intlcal_get_time_zone, ainfo_cal_only_cal )
|
||||
PHP_FE( intlcal_get_type, ainfo_cal_only_cal )
|
||||
#if U_ICU_VERSION_MAJOR_NUM * 10 + U_ICU_VERSION_MINOR_NUM >= 44
|
||||
PHP_FE( intlcal_get_weekend_transition, ainfo_cal_dow )
|
||||
#endif
|
||||
PHP_FE( intlcal_in_daylight_time, ainfo_cal_only_cal )
|
||||
PHP_FE( intlcal_is_equivalent_to, ainfo_cal_other_cal )
|
||||
PHP_FE( intlcal_is_lenient, ainfo_cal_only_cal )
|
||||
PHP_FE( intlcal_is_set, ainfo_cal_field )
|
||||
#if U_ICU_VERSION_MAJOR_NUM * 10 + U_ICU_VERSION_MINOR_NUM >= 44
|
||||
PHP_FE( intlcal_is_weekend, ainfo_cal_date_optional )
|
||||
#endif
|
||||
PHP_FE( intlcal_set_first_day_of_week, ainfo_cal_dow )
|
||||
PHP_FE( intlcal_set_lenient, ainfo_cal_set_lenient )
|
||||
PHP_FE( intlcal_equals, ainfo_cal_other_cal )
|
||||
#if U_ICU_VERSION_MAJOR_NUM >= 49
|
||||
PHP_FE( intlcal_get_repeated_wall_time_option, ainfo_cal_only_cal )
|
||||
PHP_FE( intlcal_get_skipped_wall_time_option, ainfo_cal_only_cal )
|
||||
PHP_FE( intlcal_set_repeated_wall_time_option, ainfo_cal_wall_time_option )
|
||||
PHP_FE( intlcal_set_skipped_wall_time_option, ainfo_cal_wall_time_option )
|
||||
#endif
|
||||
PHP_FE( intlcal_get_error_code, ainfo_cal_only_cal )
|
||||
PHP_FE( intlcal_get_error_message, ainfo_cal_only_cal )
|
||||
|
||||
PHP_FE( intlgregcal_create_instance, ainfo_gregcal_create_instance )
|
||||
PHP_FE( intlgregcal_set_gregorian_change, ainfo_gregcal_set_gregorian_change )
|
||||
PHP_FE( intlgregcal_get_gregorian_change, ainfo_gregcal_only_gregcal )
|
||||
PHP_FE( intlgregcal_is_leap_year, ainfo_gregcal_is_leap_year )
|
||||
|
||||
/* common functions */
|
||||
PHP_FE( intl_get_error_code, intl_0_args )
|
||||
PHP_FE( intl_get_error_message, intl_0_args )
|
||||
@ -640,6 +909,12 @@ PHP_MINIT_FUNCTION( intl )
|
||||
/* Register Transliterator constants */
|
||||
transliterator_register_constants( INIT_FUNC_ARGS_PASSTHRU );
|
||||
|
||||
/* Register 'IntlTimeZone' PHP class */
|
||||
timezone_register_IntlTimeZone_class( TSRMLS_C );
|
||||
|
||||
/* Register 'IntlCalendar' PHP class */
|
||||
calendar_register_IntlCalendar_class( TSRMLS_C );
|
||||
|
||||
/* Expose ICU error codes to PHP scripts. */
|
||||
intl_expose_icu_error_codes( INIT_FUNC_ARGS_PASSTHRU );
|
||||
|
||||
@ -657,6 +932,9 @@ PHP_MINIT_FUNCTION( intl )
|
||||
/* Register 'IntlException' PHP class */
|
||||
intl_register_IntlException_class( TSRMLS_C );
|
||||
|
||||
/* Register 'IntlIterator' PHP class */
|
||||
intl_register_IntlIterator_class( TSRMLS_C );
|
||||
|
||||
/* Global error handling. */
|
||||
intl_error_init( NULL TSRMLS_CC );
|
||||
|
||||
|
33
ext/intl/tests/calendar_add_basic.phpt
Normal file
33
ext/intl/tests/calendar_add_basic.phpt
Normal file
@ -0,0 +1,33 @@
|
||||
--TEST--
|
||||
IntlCalendar::add() basic test
|
||||
--INI--
|
||||
date.timezone=Atlantic/Azores
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded('intl'))
|
||||
die('skip intl extension not enabled');
|
||||
--FILE--
|
||||
<?php
|
||||
ini_set("intl.error_level", E_WARNING);
|
||||
ini_set("intl.default_locale", "nl");
|
||||
|
||||
$time = strtotime('2012-02-29 00:00:00 +0000');
|
||||
$time2 = strtotime('2012-03-01 05:06:07 +0000');
|
||||
|
||||
$intlcal = IntlCalendar::createInstance('UTC');
|
||||
$intlcal->setTime($time * 1000);
|
||||
$intlcal->add(IntlCalendar::FIELD_DAY_OF_MONTH, 1);
|
||||
$intlcal->add(IntlCalendar::FIELD_HOUR, 5);
|
||||
$intlcal->add(IntlCalendar::FIELD_MINUTE, 6);
|
||||
intlcal_add($intlcal, IntlCalendar::FIELD_SECOND, 7);
|
||||
|
||||
var_dump(
|
||||
(float)$time2*1000,
|
||||
$intlcal->getTime());
|
||||
|
||||
?>
|
||||
==DONE==
|
||||
--EXPECT--
|
||||
float(1330578367000)
|
||||
float(1330578367000)
|
||||
==DONE==
|
41
ext/intl/tests/calendar_add_error.phpt
Normal file
41
ext/intl/tests/calendar_add_error.phpt
Normal file
@ -0,0 +1,41 @@
|
||||
--TEST--
|
||||
IntlCalendar::add(): bad arguments
|
||||
--INI--
|
||||
date.timezone=Atlantic/Azores
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded('intl'))
|
||||
die('skip intl extension not enabled');
|
||||
--FILE--
|
||||
<?php
|
||||
ini_set("intl.error_level", E_WARNING);
|
||||
|
||||
$c = new IntlGregorianCalendar(NULL, 'pt_PT');
|
||||
|
||||
var_dump($c->add(1, 2, 3));
|
||||
var_dump($c->add(-1, 2));
|
||||
var_dump($c->add(1));
|
||||
|
||||
var_dump(intlcal_add($c, 1, 2, 3));
|
||||
var_dump(intlcal_add(1, 2, 3));
|
||||
--EXPECTF--
|
||||
|
||||
Warning: IntlCalendar::add() expects exactly 2 parameters, 3 given in %s on line %d
|
||||
|
||||
Warning: IntlCalendar::add(): intlcal_add: bad arguments in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: IntlCalendar::add(): intlcal_add: invalid field in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: IntlCalendar::add() expects exactly 2 parameters, 1 given in %s on line %d
|
||||
|
||||
Warning: IntlCalendar::add(): intlcal_add: bad arguments in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: intlcal_add() expects exactly 3 parameters, 4 given in %s on line %d
|
||||
|
||||
Warning: intlcal_add(): intlcal_add: bad arguments in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Catchable fatal error: Argument 1 passed to intlcal_add() must be an instance of IntlCalendar, integer given in %s on line %d
|
57
ext/intl/tests/calendar_before_after_error.phpt
Normal file
57
ext/intl/tests/calendar_before_after_error.phpt
Normal file
@ -0,0 +1,57 @@
|
||||
--TEST--
|
||||
IntlCalendar::before()/after(): bad arguments
|
||||
--INI--
|
||||
date.timezone=Atlantic/Azores
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded('intl'))
|
||||
die('skip intl extension not enabled');
|
||||
--FILE--
|
||||
<?php
|
||||
ini_set("intl.error_level", E_WARNING);
|
||||
|
||||
$c = new IntlGregorianCalendar(NULL, 'pt_PT');
|
||||
|
||||
function eh($errno, $errstr) {
|
||||
echo "error: $errno, $errstr\n";
|
||||
}
|
||||
set_error_handler('eh');
|
||||
|
||||
var_dump($c->after());
|
||||
var_dump($c->before());
|
||||
|
||||
var_dump($c->after(1));
|
||||
var_dump($c->before(1));
|
||||
|
||||
var_dump($c->after($c, 1));
|
||||
var_dump($c->before($c, 1));
|
||||
|
||||
var_dump(intlcal_after($c));
|
||||
var_dump(intlcal_before($c));
|
||||
--EXPECT--
|
||||
error: 2, IntlCalendar::after() expects exactly 1 parameter, 0 given
|
||||
error: 2, IntlCalendar::after(): intlcal_before/after: bad arguments
|
||||
bool(false)
|
||||
error: 2, IntlCalendar::before() expects exactly 1 parameter, 0 given
|
||||
error: 2, IntlCalendar::before(): intlcal_before/after: bad arguments
|
||||
bool(false)
|
||||
error: 4096, Argument 1 passed to IntlCalendar::after() must be an instance of IntlCalendar, integer given
|
||||
error: 2, IntlCalendar::after() expects parameter 1 to be IntlCalendar, integer given
|
||||
error: 2, IntlCalendar::after(): intlcal_before/after: bad arguments
|
||||
bool(false)
|
||||
error: 4096, Argument 1 passed to IntlCalendar::before() must be an instance of IntlCalendar, integer given
|
||||
error: 2, IntlCalendar::before() expects parameter 1 to be IntlCalendar, integer given
|
||||
error: 2, IntlCalendar::before(): intlcal_before/after: bad arguments
|
||||
bool(false)
|
||||
error: 2, IntlCalendar::after() expects exactly 1 parameter, 2 given
|
||||
error: 2, IntlCalendar::after(): intlcal_before/after: bad arguments
|
||||
bool(false)
|
||||
error: 2, IntlCalendar::before() expects exactly 1 parameter, 2 given
|
||||
error: 2, IntlCalendar::before(): intlcal_before/after: bad arguments
|
||||
bool(false)
|
||||
error: 2, intlcal_after() expects exactly 2 parameters, 1 given
|
||||
error: 2, intlcal_after(): intlcal_before/after: bad arguments
|
||||
bool(false)
|
||||
error: 2, intlcal_before() expects exactly 2 parameters, 1 given
|
||||
error: 2, intlcal_before(): intlcal_before/after: bad arguments
|
||||
bool(false)
|
40
ext/intl/tests/calendar_clear_basic.phpt
Normal file
40
ext/intl/tests/calendar_clear_basic.phpt
Normal file
@ -0,0 +1,40 @@
|
||||
--TEST--
|
||||
IntlCalendar::clear() basic test
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded('intl'))
|
||||
die('skip intl extension not enabled');
|
||||
--FILE--
|
||||
<?php
|
||||
ini_set("intl.error_level", E_WARNING);
|
||||
ini_set("intl.default_locale", "nl");
|
||||
|
||||
$intlcal = IntlCalendar::createInstance('UTC');
|
||||
var_dump($intlcal->clear());
|
||||
var_dump(
|
||||
$intlcal->get(IntlCalendar::FIELD_YEAR),
|
||||
$intlcal->get(IntlCalendar::FIELD_MONTH),
|
||||
$intlcal->get(IntlCalendar::FIELD_DAY_OF_MONTH),
|
||||
$intlcal->get(IntlCalendar::FIELD_HOUR),
|
||||
$intlcal->get(IntlCalendar::FIELD_MINUTE),
|
||||
$intlcal->get(IntlCalendar::FIELD_SECOND),
|
||||
$intlcal->get(IntlCalendar::FIELD_MILLISECOND)
|
||||
);
|
||||
|
||||
$intlcal2 = IntlCalendar::createInstance('Europe/Amsterdam');
|
||||
intlcal_clear($intlcal2, null);
|
||||
var_dump($intlcal2->getTime());
|
||||
|
||||
?>
|
||||
==DONE==
|
||||
--EXPECT--
|
||||
bool(true)
|
||||
int(1970)
|
||||
int(0)
|
||||
int(1)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
float(-3600000)
|
||||
==DONE==
|
31
ext/intl/tests/calendar_clear_error.phpt
Normal file
31
ext/intl/tests/calendar_clear_error.phpt
Normal file
@ -0,0 +1,31 @@
|
||||
--TEST--
|
||||
IntlCalendar::clear(): bad arguments
|
||||
--INI--
|
||||
date.timezone=Atlantic/Azores
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded('intl'))
|
||||
die('skip intl extension not enabled');
|
||||
--FILE--
|
||||
<?php
|
||||
ini_set("intl.error_level", E_WARNING);
|
||||
|
||||
$c = new IntlGregorianCalendar(NULL, 'pt_PT');
|
||||
|
||||
var_dump($c->clear(1, 2));
|
||||
var_dump($c->clear(-1));
|
||||
|
||||
var_dump(intlcal_clear($c, -1));
|
||||
var_dump(intlcal_clear(1, 2));
|
||||
--EXPECTF--
|
||||
|
||||
Warning: IntlCalendar::clear(): intlcal_clear: too many arguments in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: IntlCalendar::clear(): intlcal_clear: invalid field in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: intlcal_clear(): intlcal_clear: invalid field in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Catchable fatal error: Argument 1 passed to intlcal_clear() must be an instance of IntlCalendar, integer given in %s on line %d
|
33
ext/intl/tests/calendar_clear_variation1.phpt
Normal file
33
ext/intl/tests/calendar_clear_variation1.phpt
Normal file
@ -0,0 +1,33 @@
|
||||
--TEST--
|
||||
IntlCalendar::clear() 1 arg variation
|
||||
--INI--
|
||||
date.timezone=Atlantic/Azores
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded('intl'))
|
||||
die('skip intl extension not enabled');
|
||||
--FILE--
|
||||
<?php
|
||||
ini_set("intl.error_level", E_WARNING);
|
||||
ini_set("intl.default_locale", "nl");
|
||||
|
||||
$intlcal = IntlCalendar::createInstance('UTC');
|
||||
$intlcal->setTime(strtotime('2012-02-29 05:06:07 +0000') * 1000);
|
||||
//print_R($intlcal);
|
||||
var_dump($intlcal->isSet(IntlCalendar::FIELD_MONTH));
|
||||
var_dump($intlcal->clear(IntlCalendar::FIELD_MONTH));
|
||||
var_dump($intlcal->isSet(IntlCalendar::FIELD_MONTH));
|
||||
//print_R($intlcal);
|
||||
var_dump(
|
||||
$intlcal->getTime(),
|
||||
strtotime('2012-01-29 05:06:07 +0000') * 1000.
|
||||
);
|
||||
?>
|
||||
==DONE==
|
||||
--EXPECT--
|
||||
bool(true)
|
||||
bool(true)
|
||||
bool(false)
|
||||
float(1327813567000)
|
||||
float(1327813567000)
|
||||
==DONE==
|
42
ext/intl/tests/calendar_createInstance_basic.phpt
Normal file
42
ext/intl/tests/calendar_createInstance_basic.phpt
Normal file
@ -0,0 +1,42 @@
|
||||
--TEST--
|
||||
IntlCalendar::createInstance() basic test
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded('intl'))
|
||||
die('skip intl extension not enabled');
|
||||
if (version_compare(INTL_ICU_VERSION, '4.8') < 0)
|
||||
die('skip for ICU 4.8+');
|
||||
--FILE--
|
||||
<?php
|
||||
ini_set("intl.error_level", E_WARNING);
|
||||
ini_set("intl.default_locale", "nl");
|
||||
|
||||
date_default_timezone_set('Europe/Amsterdam');
|
||||
|
||||
$cal = IntlCalendar::createInstance();
|
||||
print_R($cal->getTimeZone());
|
||||
print_R($cal->getLocale(Locale::ACTUAL_LOCALE));
|
||||
echo "\n";
|
||||
print_R($cal->getType());
|
||||
echo "\n";
|
||||
|
||||
$timeMillis = $cal->getTime();
|
||||
$time = time();
|
||||
|
||||
var_dump(abs($timeMillis - $time * 1000) < 1000);
|
||||
|
||||
?>
|
||||
==DONE==
|
||||
|
||||
--EXPECTF--
|
||||
IntlTimeZone Object
|
||||
(
|
||||
[valid] => 1
|
||||
[id] => Europe/Amsterdam
|
||||
[rawOffset] => 3600000
|
||||
[currentOffset] => %d
|
||||
)
|
||||
nl
|
||||
gregorian
|
||||
bool(true)
|
||||
==DONE==
|
38
ext/intl/tests/calendar_createInstance_error.phpt
Normal file
38
ext/intl/tests/calendar_createInstance_error.phpt
Normal file
@ -0,0 +1,38 @@
|
||||
--TEST--
|
||||
IntlCalendar::createInstance: bad arguments
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded('intl'))
|
||||
die('skip intl extension not enabled');
|
||||
--FILE--
|
||||
<?php
|
||||
ini_set("intl.error_level", E_WARNING);
|
||||
|
||||
class X extends IntlTimeZone {
|
||||
function __construct() {}
|
||||
}
|
||||
|
||||
var_dump(IntlCalendar::createInstance(1, 2, 3));
|
||||
var_dump(intlcal_create_instance(1, 2, 3));
|
||||
var_dump(intlcal_create_instance(new X, NULL));
|
||||
var_dump(intlcal_create_instance(NULL, array()));
|
||||
|
||||
--EXPECTF--
|
||||
|
||||
Warning: IntlCalendar::createInstance() expects at most 2 parameters, 3 given in %s on line %d
|
||||
|
||||
Warning: IntlCalendar::createInstance(): intlcal_create_calendar: bad arguments in %s on line %d
|
||||
NULL
|
||||
|
||||
Warning: intlcal_create_instance() expects at most 2 parameters, 3 given in %s on line %d
|
||||
|
||||
Warning: intlcal_create_instance(): intlcal_create_calendar: bad arguments in %s on line %d
|
||||
NULL
|
||||
|
||||
Warning: intlcal_create_instance(): intlcal_create_instance: passed IntlTimeZone is not properly constructed in %s on line %d
|
||||
NULL
|
||||
|
||||
Warning: intlcal_create_instance() expects parameter 2 to be string, array given in %s on line %d
|
||||
|
||||
Warning: intlcal_create_instance(): intlcal_create_calendar: bad arguments in %s on line %d
|
||||
NULL
|
84
ext/intl/tests/calendar_createInstance_variation1.phpt
Normal file
84
ext/intl/tests/calendar_createInstance_variation1.phpt
Normal file
@ -0,0 +1,84 @@
|
||||
--TEST--
|
||||
IntlCalendar::createInstance() argument variations
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded('intl'))
|
||||
die('skip intl extension not enabled');
|
||||
if (version_compare(INTL_ICU_VERSION, '4.8') < 0)
|
||||
die('skip for ICU 4.8+');
|
||||
--FILE--
|
||||
<?php
|
||||
ini_set("intl.error_level", E_WARNING);
|
||||
ini_set("intl.default_locale", "nl");
|
||||
|
||||
date_default_timezone_set('Europe/Amsterdam');
|
||||
|
||||
$cal = intlcal_create_instance('Europe/Amsterdam');
|
||||
print_R($cal->getTimeZone());
|
||||
print_R($cal->getLocale(Locale::ACTUAL_LOCALE));
|
||||
echo "\n";
|
||||
|
||||
$cal = intlcal_create_instance('Europe/Lisbon', null);
|
||||
print_R($cal->getTimeZone());
|
||||
print_R($cal->getLocale(Locale::ACTUAL_LOCALE));
|
||||
echo "\n";
|
||||
|
||||
$cal = intlcal_create_instance(IntlTimeZone::createTimeZone('Europe/Lisbon'));
|
||||
print_R($cal->getTimeZone());
|
||||
print_R($cal->getLocale(Locale::ACTUAL_LOCALE));
|
||||
echo "\n";
|
||||
|
||||
$cal = intlcal_create_instance(null, "pt");
|
||||
print_R($cal->getTimeZone());
|
||||
print_R($cal->getLocale(Locale::ACTUAL_LOCALE));
|
||||
echo "\n";
|
||||
|
||||
$cal = intlcal_create_instance("Europe/Lisbon", "pt");
|
||||
print_R($cal->getTimeZone());
|
||||
print_R($cal->getLocale(Locale::ACTUAL_LOCALE));
|
||||
echo "\n";
|
||||
|
||||
?>
|
||||
==DONE==
|
||||
--EXPECTF--
|
||||
IntlTimeZone Object
|
||||
(
|
||||
[valid] => 1
|
||||
[id] => Europe/Amsterdam
|
||||
[rawOffset] => 3600000
|
||||
[currentOffset] => %d
|
||||
)
|
||||
nl
|
||||
IntlTimeZone Object
|
||||
(
|
||||
[valid] => 1
|
||||
[id] => Europe/Lisbon
|
||||
[rawOffset] => 0
|
||||
[currentOffset] => %d
|
||||
)
|
||||
nl
|
||||
IntlTimeZone Object
|
||||
(
|
||||
[valid] => 1
|
||||
[id] => Europe/Lisbon
|
||||
[rawOffset] => 0
|
||||
[currentOffset] => %d
|
||||
)
|
||||
nl
|
||||
IntlTimeZone Object
|
||||
(
|
||||
[valid] => 1
|
||||
[id] => Europe/Amsterdam
|
||||
[rawOffset] => 3600000
|
||||
[currentOffset] => %d
|
||||
)
|
||||
pt
|
||||
IntlTimeZone Object
|
||||
(
|
||||
[valid] => 1
|
||||
[id] => Europe/Lisbon
|
||||
[rawOffset] => 0
|
||||
[currentOffset] => %d
|
||||
)
|
||||
pt
|
||||
==DONE==
|
59
ext/intl/tests/calendar_equals_before_after_basic.phpt
Normal file
59
ext/intl/tests/calendar_equals_before_after_basic.phpt
Normal file
@ -0,0 +1,59 @@
|
||||
--TEST--
|
||||
IntlCalendar::equals(), ::before() and ::after() basic test
|
||||
--INI--
|
||||
date.timezone=Atlantic/Azores
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded('intl'))
|
||||
die('skip intl extension not enabled');
|
||||
--FILE--
|
||||
<?php
|
||||
ini_set("intl.error_level", E_WARNING);
|
||||
ini_set("intl.default_locale", "nl");
|
||||
|
||||
$intlcal1 = new IntlGregorianCalendar(2012, 1, 29, 16, 59, 59);
|
||||
$intlcal2 = IntlCalendar::createInstance(null, '@calendar=japanese');
|
||||
$intlcal3 = new IntlGregorianCalendar(2012, 1, 29, 17, 00, 00);
|
||||
$intlcal2->setTime($intlcal1->getTime());
|
||||
|
||||
var_dump($intlcal2->getType());
|
||||
|
||||
var_dump("1 eq 1", $intlcal1->equals($intlcal1));
|
||||
|
||||
var_dump("1 eq 2", $intlcal1->equals($intlcal2));
|
||||
var_dump("1 before 2", $intlcal1->before($intlcal2));
|
||||
var_dump("1 after 2", $intlcal1->after($intlcal2));
|
||||
|
||||
var_dump("1 eq 3", $intlcal1->equals($intlcal3));
|
||||
var_dump("1 before 3", $intlcal1->before($intlcal3));
|
||||
var_dump("1 after 3", $intlcal1->after($intlcal3));
|
||||
|
||||
var_dump("3 eq 2", intlcal_equals($intlcal3, $intlcal2));
|
||||
var_dump("3 before 2", intlcal_before($intlcal3, $intlcal2));
|
||||
var_dump("3 after 2", intlcal_after($intlcal3, $intlcal2));
|
||||
|
||||
?>
|
||||
==DONE==
|
||||
--EXPECT--
|
||||
string(8) "japanese"
|
||||
string(6) "1 eq 1"
|
||||
bool(true)
|
||||
string(6) "1 eq 2"
|
||||
bool(true)
|
||||
string(10) "1 before 2"
|
||||
bool(false)
|
||||
string(9) "1 after 2"
|
||||
bool(false)
|
||||
string(6) "1 eq 3"
|
||||
bool(false)
|
||||
string(10) "1 before 3"
|
||||
bool(true)
|
||||
string(9) "1 after 3"
|
||||
bool(false)
|
||||
string(6) "3 eq 2"
|
||||
bool(false)
|
||||
string(10) "3 before 2"
|
||||
bool(false)
|
||||
string(9) "3 after 2"
|
||||
bool(true)
|
||||
==DONE==
|
46
ext/intl/tests/calendar_equals_error.phpt
Normal file
46
ext/intl/tests/calendar_equals_error.phpt
Normal file
@ -0,0 +1,46 @@
|
||||
--TEST--
|
||||
IntlCalendar::equals(): bad arguments
|
||||
--INI--
|
||||
date.timezone=Atlantic/Azores
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded('intl'))
|
||||
die('skip intl extension not enabled');
|
||||
--FILE--
|
||||
<?php
|
||||
ini_set("intl.error_level", E_WARNING);
|
||||
|
||||
$c = new IntlGregorianCalendar(NULL, 'pt_PT');
|
||||
|
||||
function eh($errno, $errstr) {
|
||||
echo "error: $errno, $errstr\n";
|
||||
}
|
||||
set_error_handler('eh');
|
||||
|
||||
var_dump($c->equals());
|
||||
var_dump($c->equals(new stdclass));
|
||||
var_dump($c->equals(1, 2));
|
||||
|
||||
var_dump(intlcal_equals($c, array()));
|
||||
var_dump(intlcal_equals(1, $c));
|
||||
|
||||
--EXPECT--
|
||||
error: 2, IntlCalendar::equals() expects exactly 1 parameter, 0 given
|
||||
error: 2, IntlCalendar::equals(): intlcal_equals: bad arguments
|
||||
bool(false)
|
||||
error: 4096, Argument 1 passed to IntlCalendar::equals() must be an instance of IntlCalendar, instance of stdClass given
|
||||
error: 2, IntlCalendar::equals() expects parameter 1 to be IntlCalendar, object given
|
||||
error: 2, IntlCalendar::equals(): intlcal_equals: bad arguments
|
||||
bool(false)
|
||||
error: 4096, Argument 1 passed to IntlCalendar::equals() must be an instance of IntlCalendar, integer given
|
||||
error: 2, IntlCalendar::equals() expects exactly 1 parameter, 2 given
|
||||
error: 2, IntlCalendar::equals(): intlcal_equals: bad arguments
|
||||
bool(false)
|
||||
error: 4096, Argument 2 passed to intlcal_equals() must be an instance of IntlCalendar, array given
|
||||
error: 2, intlcal_equals() expects parameter 2 to be IntlCalendar, array given
|
||||
error: 2, intlcal_equals(): intlcal_equals: bad arguments
|
||||
bool(false)
|
||||
error: 4096, Argument 1 passed to intlcal_equals() must be an instance of IntlCalendar, integer given
|
||||
error: 2, intlcal_equals() expects parameter 1 to be IntlCalendar, integer given
|
||||
error: 2, intlcal_equals(): intlcal_equals: bad arguments
|
||||
bool(false)
|
35
ext/intl/tests/calendar_fieldDifference_basic.phpt
Normal file
35
ext/intl/tests/calendar_fieldDifference_basic.phpt
Normal file
@ -0,0 +1,35 @@
|
||||
--TEST--
|
||||
IntlCalendar::fieldDifference() basic test
|
||||
--INI--
|
||||
date.timezone=Atlantic/Azores
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded('intl'))
|
||||
die('skip intl extension not enabled');
|
||||
--FILE--
|
||||
<?php
|
||||
ini_set("intl.error_level", E_WARNING);
|
||||
ini_set("intl.default_locale", "nl");
|
||||
|
||||
$intlcal = IntlCalendar::createInstance('UTC');
|
||||
$intlcal->setTime(strtotime('2012-02-29 05:06:07 +0000') * 1000);
|
||||
var_dump(
|
||||
$intlcal->fieldDifference(
|
||||
strtotime('2012-02-29 06:06:08 +0000') * 1000,
|
||||
IntlCalendar::FIELD_SECOND),
|
||||
$intlcal->get(IntlCalendar::FIELD_HOUR_OF_DAY));
|
||||
|
||||
|
||||
$intlcal->setTime(strtotime('2012-02-29 05:06:07 +0000') * 1000);
|
||||
var_dump(
|
||||
intlcal_field_difference(
|
||||
$intlcal,
|
||||
strtotime('2012-02-29 06:07:08 +0000') * 1000,
|
||||
IntlCalendar::FIELD_MINUTE));
|
||||
?>
|
||||
==DONE==
|
||||
--EXPECT--
|
||||
int(3601)
|
||||
int(6)
|
||||
int(61)
|
||||
==DONE==
|
42
ext/intl/tests/calendar_fieldDifference_error.phpt
Normal file
42
ext/intl/tests/calendar_fieldDifference_error.phpt
Normal file
@ -0,0 +1,42 @@
|
||||
--TEST--
|
||||
IntlCalendar::fieldDifference(): bad arguments
|
||||
--INI--
|
||||
date.timezone=Atlantic/Azores
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded('intl'))
|
||||
die('skip intl extension not enabled');
|
||||
--FILE--
|
||||
<?php
|
||||
ini_set("intl.error_level", E_WARNING);
|
||||
|
||||
$c = new IntlGregorianCalendar(NULL, 'pt_PT');
|
||||
|
||||
var_dump($c->fieldDifference($c, 2, 3));
|
||||
var_dump($c->fieldDifference(INF, 2));
|
||||
var_dump($c->fieldDifference(1));
|
||||
|
||||
var_dump(intlcal_field_difference($c, 0, 1, 2));
|
||||
var_dump(intlcal_field_difference(1, 0, 1));
|
||||
|
||||
--EXPECTF--
|
||||
|
||||
Warning: IntlCalendar::fieldDifference() expects exactly 2 parameters, 3 given in %s on line %d
|
||||
|
||||
Warning: IntlCalendar::fieldDifference(): intlcal_field_difference: bad arguments in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: IntlCalendar::fieldDifference(): intlcal_field_difference: Call to ICU method has failed in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: IntlCalendar::fieldDifference() expects exactly 2 parameters, 1 given in %s on line %d
|
||||
|
||||
Warning: IntlCalendar::fieldDifference(): intlcal_field_difference: bad arguments in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: intlcal_field_difference() expects exactly 3 parameters, 4 given in %s on line %d
|
||||
|
||||
Warning: intlcal_field_difference(): intlcal_field_difference: bad arguments in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Catchable fatal error: Argument 1 passed to intlcal_field_difference() must be an instance of IntlCalendar, integer given in %s on line %d
|
23
ext/intl/tests/calendar_getAvailableLocales_basic.phpt
Normal file
23
ext/intl/tests/calendar_getAvailableLocales_basic.phpt
Normal file
@ -0,0 +1,23 @@
|
||||
--TEST--
|
||||
IntlCalendar::getAvailableLocales() basic test
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded('intl'))
|
||||
die('skip intl extension not enabled');
|
||||
--FILE--
|
||||
<?php
|
||||
ini_set("intl.error_level", E_WARNING);
|
||||
ini_set("intl.default_locale", "nl");
|
||||
|
||||
$locales = IntlCalendar::getAvailableLocales();
|
||||
var_dump(count($locales) > 100);
|
||||
|
||||
$locales = intlcal_get_available_locales();
|
||||
var_dump(in_array('pt', $locales));
|
||||
|
||||
?>
|
||||
==DONE==
|
||||
--EXPECT--
|
||||
bool(true)
|
||||
bool(true)
|
||||
==DONE==
|
24
ext/intl/tests/calendar_getAvailableLocales_error.phpt
Normal file
24
ext/intl/tests/calendar_getAvailableLocales_error.phpt
Normal file
@ -0,0 +1,24 @@
|
||||
--TEST--
|
||||
IntlCalendar::getAvailableLocales(): bad arguments
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded('intl'))
|
||||
die('skip intl extension not enabled');
|
||||
--FILE--
|
||||
<?php
|
||||
ini_set("intl.error_level", E_WARNING);
|
||||
|
||||
var_dump(intlcal_get_available_locales(1));
|
||||
var_dump(IntlCalendar::getAvailableLocales(2));
|
||||
|
||||
--EXPECTF--
|
||||
|
||||
Warning: intlcal_get_available_locales() expects exactly 0 parameters, 1 given in %s on line %d
|
||||
|
||||
Warning: intlcal_get_available_locales(): intlcal_get_available_locales: bad arguments in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: IntlCalendar::getAvailableLocales() expects exactly 0 parameters, 1 given in %s on line %d
|
||||
|
||||
Warning: IntlCalendar::getAvailableLocales(): intlcal_get_available_locales: bad arguments in %s on line %d
|
||||
bool(false)
|
34
ext/intl/tests/calendar_getDayOfWeekType_basic.phpt
Normal file
34
ext/intl/tests/calendar_getDayOfWeekType_basic.phpt
Normal file
@ -0,0 +1,34 @@
|
||||
--TEST--
|
||||
IntlCalendar::getDayOfWeekType() basic test
|
||||
--INI--
|
||||
date.timezone=Atlantic/Azores
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded('intl'))
|
||||
die('skip intl extension not enabled');
|
||||
if (version_compare(INTL_ICU_VERSION, '4.4') < 0)
|
||||
die('skip for ICU 4.4+');
|
||||
--FILE--
|
||||
<?php
|
||||
ini_set("intl.error_level", E_WARNING);
|
||||
ini_set("intl.default_locale", "nl");
|
||||
|
||||
$intlcal = IntlCalendar::createInstance('UTC');
|
||||
$intlcal->setTime(strtotime('2012-02-29 00:00:00 +0000') * 1000);
|
||||
var_dump(
|
||||
intlcal_get_day_of_week_type($intlcal, IntlCalendar::DOW_SUNDAY),
|
||||
$intlcal->getDayOfWeekType(IntlCalendar::DOW_MONDAY),
|
||||
$intlcal->getDayOfWeekType(IntlCalendar::DOW_TUESDAY),
|
||||
$intlcal->getDayOfWeekType(IntlCalendar::DOW_FRIDAY),
|
||||
$intlcal->getDayOfWeekType(IntlCalendar::DOW_SATURDAY)
|
||||
);
|
||||
|
||||
?>
|
||||
==DONE==
|
||||
--EXPECT--
|
||||
int(3)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
int(1)
|
||||
==DONE==
|
44
ext/intl/tests/calendar_getDayOfWeekType_error.phpt
Normal file
44
ext/intl/tests/calendar_getDayOfWeekType_error.phpt
Normal file
@ -0,0 +1,44 @@
|
||||
--TEST--
|
||||
IntlCalendar::getDayOfWeekOfType(): bad arguments
|
||||
--INI--
|
||||
date.timezone=Atlantic/Azores
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded('intl'))
|
||||
die('skip intl extension not enabled');
|
||||
if (version_compare(INTL_ICU_VERSION, '4.4') < 0)
|
||||
die('skip for ICU 4.4+');
|
||||
--FILE--
|
||||
<?php
|
||||
ini_set("intl.error_level", E_WARNING);
|
||||
|
||||
$c = new IntlGregorianCalendar(NULL, 'pt_PT');
|
||||
|
||||
var_dump($c->getDayOfWeekType(1, 2));
|
||||
var_dump($c->getDayOfWeekType(0));
|
||||
var_dump($c->getDayOfWeekType());
|
||||
|
||||
var_dump(intlcal_get_day_of_week_type($c, "foo"));
|
||||
var_dump(intlcal_get_day_of_week_type(1, 1));
|
||||
|
||||
--EXPECTF--
|
||||
|
||||
Warning: IntlCalendar::getDayOfWeekType() expects exactly 1 parameter, 2 given in %s on line %d
|
||||
|
||||
Warning: IntlCalendar::getDayOfWeekType(): intlcal_get_day_of_week_type: bad arguments in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: IntlCalendar::getDayOfWeekType(): intlcal_get_day_of_week_type: invalid day of week in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: IntlCalendar::getDayOfWeekType() expects exactly 1 parameter, 0 given in %s on line %d
|
||||
|
||||
Warning: IntlCalendar::getDayOfWeekType(): intlcal_get_day_of_week_type: bad arguments in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: intlcal_get_day_of_week_type() expects parameter 2 to be long, string given in %s on line %d
|
||||
|
||||
Warning: intlcal_get_day_of_week_type(): intlcal_get_day_of_week_type: bad arguments in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Catchable fatal error: Argument 1 passed to intlcal_get_day_of_week_type() must be an instance of IntlCalendar, integer given in %s on line %d
|
26
ext/intl/tests/calendar_getErrorCode_error.phpt
Normal file
26
ext/intl/tests/calendar_getErrorCode_error.phpt
Normal file
@ -0,0 +1,26 @@
|
||||
--TEST--
|
||||
IntlCalendar::getErrorCode(): bad arguments
|
||||
--INI--
|
||||
date.timezone=Atlantic/Azores
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded('intl'))
|
||||
die('skip intl extension not enabled');
|
||||
--FILE--
|
||||
<?php
|
||||
ini_set("intl.error_level", E_WARNING);
|
||||
|
||||
$c = new IntlGregorianCalendar(NULL, 'pt_PT');
|
||||
|
||||
var_dump($c->getErrorCode(array()));
|
||||
|
||||
var_dump(intlcal_get_error_code(null));
|
||||
|
||||
--EXPECTF--
|
||||
|
||||
Warning: IntlCalendar::getErrorCode() expects exactly 0 parameters, 1 given in %s on line %d
|
||||
|
||||
Warning: IntlCalendar::getErrorCode(): intlcal_get_error_code: bad arguments in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Catchable fatal error: Argument 1 passed to intlcal_get_error_code() must be an instance of IntlCalendar, null given in %s on line %d
|
@ -0,0 +1,43 @@
|
||||
--TEST--
|
||||
IntlCalendar::getErrorCode(), ::getErrorMessage() basic test
|
||||
--INI--
|
||||
date.timezone=Atlantic/Azores
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded('intl'))
|
||||
die('skip intl extension not enabled');
|
||||
--FILE--
|
||||
<?php
|
||||
ini_set("intl.error_level", E_WARNING);
|
||||
ini_set("intl.default_locale", "nl");
|
||||
|
||||
$intlcal = new IntlGregorianCalendar(2012, 1, 29);
|
||||
var_dump(
|
||||
$intlcal->getErrorCode(),
|
||||
intlcal_get_error_code($intlcal),
|
||||
$intlcal->getErrorMessage(),
|
||||
intlcal_get_error_message($intlcal)
|
||||
);
|
||||
$intlcal->add(IntlCalendar::FIELD_SECOND, 2147483647);
|
||||
$intlcal->fieldDifference(-PHP_INT_MAX, IntlCalendar::FIELD_SECOND);
|
||||
|
||||
var_dump(
|
||||
$intlcal->getErrorCode(),
|
||||
intlcal_get_error_code($intlcal),
|
||||
$intlcal->getErrorMessage(),
|
||||
intlcal_get_error_message($intlcal)
|
||||
);
|
||||
?>
|
||||
==DONE==
|
||||
--EXPECTF--
|
||||
int(0)
|
||||
int(0)
|
||||
string(12) "U_ZERO_ERROR"
|
||||
string(12) "U_ZERO_ERROR"
|
||||
|
||||
Warning: IntlCalendar::fieldDifference(): intlcal_field_difference: Call to ICU method has failed in %s on line %d
|
||||
int(1)
|
||||
int(1)
|
||||
string(81) "intlcal_field_difference: Call to ICU method has failed: U_ILLEGAL_ARGUMENT_ERROR"
|
||||
string(81) "intlcal_field_difference: Call to ICU method has failed: U_ILLEGAL_ARGUMENT_ERROR"
|
||||
==DONE==
|
26
ext/intl/tests/calendar_getErrorMessage_error.phpt
Normal file
26
ext/intl/tests/calendar_getErrorMessage_error.phpt
Normal file
@ -0,0 +1,26 @@
|
||||
--TEST--
|
||||
IntlCalendar::getErrorMessage(): bad arguments
|
||||
--INI--
|
||||
date.timezone=Atlantic/Azores
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded('intl'))
|
||||
die('skip intl extension not enabled');
|
||||
--FILE--
|
||||
<?php
|
||||
ini_set("intl.error_level", E_WARNING);
|
||||
|
||||
$c = new IntlGregorianCalendar(NULL, 'pt_PT');
|
||||
|
||||
var_dump($c->getErrorMessage(array()));
|
||||
|
||||
var_dump(intlcal_get_error_message(null));
|
||||
|
||||
--EXPECTF--
|
||||
|
||||
Warning: IntlCalendar::getErrorMessage() expects exactly 0 parameters, 1 given in %s on line %d
|
||||
|
||||
Warning: IntlCalendar::getErrorMessage(): intlcal_get_error_message: bad arguments in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Catchable fatal error: Argument 1 passed to intlcal_get_error_message() must be an instance of IntlCalendar, null given in %s on line %d
|
20
ext/intl/tests/calendar_getFirstDayOfWeek_basic.phpt
Normal file
20
ext/intl/tests/calendar_getFirstDayOfWeek_basic.phpt
Normal file
@ -0,0 +1,20 @@
|
||||
--TEST--
|
||||
IntlCalendar::getFirstDayOfWeek() basic test
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded('intl'))
|
||||
die('skip intl extension not enabled');
|
||||
--FILE--
|
||||
<?php
|
||||
ini_set("intl.error_level", E_WARNING);
|
||||
ini_set("intl.default_locale", "nl");
|
||||
|
||||
$intlcal = IntlCalendar::createInstance('UTC');
|
||||
var_dump($intlcal->getFirstDayOfWeek());
|
||||
var_dump(intlcal_get_first_day_of_week($intlcal));
|
||||
?>
|
||||
==DONE==
|
||||
--EXPECT--
|
||||
int(2)
|
||||
int(2)
|
||||
==DONE==
|
32
ext/intl/tests/calendar_getFirstDayOfWeek_error.phpt
Normal file
32
ext/intl/tests/calendar_getFirstDayOfWeek_error.phpt
Normal file
@ -0,0 +1,32 @@
|
||||
--TEST--
|
||||
IntlCalendar::getFirstDayOfWeek(): bad arguments
|
||||
--INI--
|
||||
date.timezone=Atlantic/Azores
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded('intl'))
|
||||
die('skip intl extension not enabled');
|
||||
--FILE--
|
||||
<?php
|
||||
ini_set("intl.error_level", E_WARNING);
|
||||
|
||||
$c = new IntlGregorianCalendar(NULL, 'pt_PT');
|
||||
|
||||
var_dump($c->getFirstDayOfWeek(1));
|
||||
|
||||
var_dump(intlcal_get_first_day_of_week($c, 1));
|
||||
var_dump(intlcal_get_first_day_of_week(1));
|
||||
|
||||
--EXPECTF--
|
||||
|
||||
Warning: IntlCalendar::getFirstDayOfWeek() expects exactly 0 parameters, 1 given in %s on line %d
|
||||
|
||||
Warning: IntlCalendar::getFirstDayOfWeek(): intlcal_get_first_day_of_week: bad arguments in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: intlcal_get_first_day_of_week() expects exactly 1 parameter, 2 given in %s on line %d
|
||||
|
||||
Warning: intlcal_get_first_day_of_week(): intlcal_get_first_day_of_week: bad arguments in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Catchable fatal error: Argument 1 passed to intlcal_get_first_day_of_week() must be an instance of IntlCalendar, integer given in %s on line %d
|
36
ext/intl/tests/calendar_getKeywordValuesForLocale_basic.phpt
Normal file
36
ext/intl/tests/calendar_getKeywordValuesForLocale_basic.phpt
Normal file
@ -0,0 +1,36 @@
|
||||
--TEST--
|
||||
IntlCalendar::getKeywordValuesForLocale() basic test
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded('intl'))
|
||||
die('skip intl extension not enabled');
|
||||
if (version_compare(INTL_ICU_VERSION, '4.2') < 0)
|
||||
die('skip for ICU 4.2+');
|
||||
--FILE--
|
||||
<?php
|
||||
ini_set("intl.error_level", E_WARNING);
|
||||
ini_set("intl.default_locale", "nl");
|
||||
|
||||
print_r(
|
||||
iterator_to_array(
|
||||
IntlCalendar::getKeywordValuesForLocale('calendar', 'pt', true)
|
||||
));
|
||||
echo "\n";
|
||||
|
||||
$var = iterator_to_array(
|
||||
intlcal_get_keyword_values_for_locale('calendar', 'pt', false)
|
||||
);
|
||||
var_dump(count($var) > 8);
|
||||
var_dump(in_array('japanese', $var));
|
||||
|
||||
?>
|
||||
==DONE==
|
||||
--EXPECT--
|
||||
Array
|
||||
(
|
||||
[0] => gregorian
|
||||
)
|
||||
|
||||
bool(true)
|
||||
bool(true)
|
||||
==DONE==
|
26
ext/intl/tests/calendar_getKeywordValuesForLocale_error.phpt
Normal file
26
ext/intl/tests/calendar_getKeywordValuesForLocale_error.phpt
Normal file
@ -0,0 +1,26 @@
|
||||
--TEST--
|
||||
IntlCalendar::getKeywordValuesForLocale(): bad arguments
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded('intl'))
|
||||
die('skip intl extension not enabled');
|
||||
if (version_compare(INTL_ICU_VERSION, '4.2') < 0)
|
||||
die('skip for ICU 4.2+');
|
||||
--FILE--
|
||||
<?php
|
||||
ini_set("intl.error_level", E_WARNING);
|
||||
|
||||
var_dump(intlcal_get_keyword_values_for_locale(1, 2));
|
||||
var_dump(IntlCalendar::getKeywordValuesForLocale(1, 2, array()));
|
||||
|
||||
--EXPECTF--
|
||||
|
||||
Warning: intlcal_get_keyword_values_for_locale() expects exactly 3 parameters, 2 given in %s on line %d
|
||||
|
||||
Warning: intlcal_get_keyword_values_for_locale(): intlcal_get_keyword_values_for_locale: bad arguments in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: IntlCalendar::getKeywordValuesForLocale() expects parameter 3 to be boolean, array given in %s on line %d
|
||||
|
||||
Warning: IntlCalendar::getKeywordValuesForLocale(): intlcal_get_keyword_values_for_locale: bad arguments in %s on line %d
|
||||
bool(false)
|
22
ext/intl/tests/calendar_getLocale_basic.phpt
Normal file
22
ext/intl/tests/calendar_getLocale_basic.phpt
Normal file
@ -0,0 +1,22 @@
|
||||
--TEST--
|
||||
IntlCalendar::getLocale() basic test
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded('intl'))
|
||||
die('skip intl extension not enabled');
|
||||
if (version_compare(INTL_ICU_VERSION, '4.8') < 0)
|
||||
die('skip for ICU 4.8+');
|
||||
--FILE--
|
||||
<?php
|
||||
ini_set("intl.error_level", E_WARNING);
|
||||
ini_set("intl.default_locale", "nl");
|
||||
|
||||
$intlcal = IntlCalendar::createInstance('UTC');
|
||||
var_dump($intlcal->getLocale(Locale::ACTUAL_LOCALE));
|
||||
var_dump(intlcal_get_locale($intlcal, Locale::VALID_LOCALE));
|
||||
?>
|
||||
==DONE==
|
||||
--EXPECT--
|
||||
string(2) "nl"
|
||||
string(5) "nl_NL"
|
||||
==DONE==
|
42
ext/intl/tests/calendar_getLocale_error.phpt
Normal file
42
ext/intl/tests/calendar_getLocale_error.phpt
Normal file
@ -0,0 +1,42 @@
|
||||
--TEST--
|
||||
IntlCalendar::getLocale(): bad arguments
|
||||
--INI--
|
||||
date.timezone=Atlantic/Azores
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded('intl'))
|
||||
die('skip intl extension not enabled');
|
||||
--FILE--
|
||||
<?php
|
||||
ini_set("intl.error_level", E_WARNING);
|
||||
|
||||
$c = new IntlGregorianCalendar(NULL, 'pt_PT');
|
||||
|
||||
var_dump($c->getLocale());
|
||||
var_dump($c->getLocale(2));
|
||||
var_dump($c->getLocale(2, 3));
|
||||
|
||||
var_dump(intlcal_get_locale($c));
|
||||
var_dump(intlcal_get_locale(1));
|
||||
|
||||
--EXPECTF--
|
||||
|
||||
Warning: IntlCalendar::getLocale() expects exactly 1 parameter, 0 given in %s on line %d
|
||||
|
||||
Warning: IntlCalendar::getLocale(): intlcal_get_locale: bad arguments in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: IntlCalendar::getLocale(): intlcal_get_locale: invalid locale type in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: IntlCalendar::getLocale() expects exactly 1 parameter, 2 given in %s on line %d
|
||||
|
||||
Warning: IntlCalendar::getLocale(): intlcal_get_locale: bad arguments in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: intlcal_get_locale() expects exactly 2 parameters, 1 given in %s on line %d
|
||||
|
||||
Warning: intlcal_get_locale(): intlcal_get_locale: bad arguments in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Catchable fatal error: Argument 1 passed to intlcal_get_locale() must be an instance of IntlCalendar, integer given in %s on line %d
|
22
ext/intl/tests/calendar_getMinimalDaysInFirstWeek_basic.phpt
Normal file
22
ext/intl/tests/calendar_getMinimalDaysInFirstWeek_basic.phpt
Normal file
@ -0,0 +1,22 @@
|
||||
--TEST--
|
||||
IntlCalendar::getMinimalDaysInFirstWeek() basic test
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded('intl'))
|
||||
die('skip intl extension not enabled');
|
||||
if (version_compare(INTL_ICU_VERSION, '4.8') < 0)
|
||||
die('skip for ICU 4.8+');
|
||||
--FILE--
|
||||
<?php
|
||||
ini_set("intl.error_level", E_WARNING);
|
||||
ini_set("intl.default_locale", "nl");
|
||||
|
||||
$intlcal = IntlCalendar::createInstance('UTC');
|
||||
var_dump($intlcal->getMinimalDaysInFirstWeek());
|
||||
var_dump(intlcal_get_minimal_days_in_first_week($intlcal));
|
||||
?>
|
||||
==DONE==
|
||||
--EXPECT--
|
||||
int(4)
|
||||
int(4)
|
||||
==DONE==
|
32
ext/intl/tests/calendar_getMinimalDaysInFirstWeek_error.phpt
Normal file
32
ext/intl/tests/calendar_getMinimalDaysInFirstWeek_error.phpt
Normal file
@ -0,0 +1,32 @@
|
||||
--TEST--
|
||||
IntlCalendar::getMinimalDaysInFirstWeek(): bad arguments
|
||||
--INI--
|
||||
date.timezone=Atlantic/Azores
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded('intl'))
|
||||
die('skip intl extension not enabled');
|
||||
--FILE--
|
||||
<?php
|
||||
ini_set("intl.error_level", E_WARNING);
|
||||
|
||||
$c = new IntlGregorianCalendar(NULL, 'pt_PT');
|
||||
|
||||
var_dump($c->getMinimalDaysInFirstWeek(1));
|
||||
|
||||
var_dump(intlcal_get_minimal_days_in_first_week($c, 1));
|
||||
var_dump(intlcal_get_minimal_days_in_first_week(1));
|
||||
|
||||
--EXPECTF--
|
||||
|
||||
Warning: IntlCalendar::getMinimalDaysInFirstWeek() expects exactly 0 parameters, 1 given in %s on line %d
|
||||
|
||||
Warning: IntlCalendar::getMinimalDaysInFirstWeek(): intlcal_get_minimal_days_in_first_week: bad arguments in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: intlcal_get_minimal_days_in_first_week() expects exactly 1 parameter, 2 given in %s on line %d
|
||||
|
||||
Warning: intlcal_get_minimal_days_in_first_week(): intlcal_get_minimal_days_in_first_week: bad arguments in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Catchable fatal error: Argument 1 passed to intlcal_get_minimal_days_in_first_week() must be an instance of IntlCalendar, integer given in %s on line %d
|
23
ext/intl/tests/calendar_getNow_basic.phpt
Normal file
23
ext/intl/tests/calendar_getNow_basic.phpt
Normal file
@ -0,0 +1,23 @@
|
||||
--TEST--
|
||||
IntlCalendar::getNow() basic test
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded('intl'))
|
||||
die('skip intl extension not enabled');
|
||||
--FILE--
|
||||
<?php
|
||||
ini_set("intl.error_level", E_WARNING);
|
||||
ini_set("intl.default_locale", "nl");
|
||||
|
||||
$now = IntlCalendar::getNow();
|
||||
$proc_now = intlcal_get_now();
|
||||
$time = time();
|
||||
var_dump(abs($now - $proc_now) < 500);
|
||||
var_dump(abs($time * 1000 - $proc_now) < 1000);
|
||||
|
||||
?>
|
||||
==DONE==
|
||||
--EXPECT--
|
||||
bool(true)
|
||||
bool(true)
|
||||
==DONE==
|
24
ext/intl/tests/calendar_getNow_error.phpt
Normal file
24
ext/intl/tests/calendar_getNow_error.phpt
Normal file
@ -0,0 +1,24 @@
|
||||
--TEST--
|
||||
IntlCalendar::getNow(): bad arguments
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded('intl'))
|
||||
die('skip intl extension not enabled');
|
||||
--FILE--
|
||||
<?php
|
||||
ini_set("intl.error_level", E_WARNING);
|
||||
|
||||
var_dump(intlcal_get_now(1));
|
||||
var_dump(IntlCalendar::getNow(2));
|
||||
|
||||
--EXPECTF--
|
||||
|
||||
Warning: intlcal_get_now() expects exactly 0 parameters, 1 given in %s on line %d
|
||||
|
||||
Warning: intlcal_get_now(): intlcal_get_now: bad arguments in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: IntlCalendar::getNow() expects exactly 0 parameters, 1 given in %s on line %d
|
||||
|
||||
Warning: IntlCalendar::getNow(): intlcal_get_now: bad arguments in %s on line %d
|
||||
bool(false)
|
@ -0,0 +1,47 @@
|
||||
--TEST--
|
||||
IntlCalendar::getSkipped/RepeatedWallTimeOption(): bad arguments
|
||||
--INI--
|
||||
date.timezone=Atlantic/Azores
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded('intl'))
|
||||
die('skip intl extension not enabled');
|
||||
if (version_compare(INTL_ICU_VERSION, '49') < 0)
|
||||
die('skip for ICU 49+');
|
||||
--FILE--
|
||||
<?php
|
||||
ini_set("intl.error_level", E_WARNING);
|
||||
|
||||
$c = new IntlGregorianCalendar(NULL, 'pt_PT');
|
||||
|
||||
var_dump($c->getSkippedWallTimeOption(1));
|
||||
var_dump($c->getRepeatedWallTimeOption(1));
|
||||
|
||||
var_dump(intlcal_get_skipped_wall_time_option($c, 1));
|
||||
var_dump(intlcal_get_repeated_wall_time_option($c, 1));
|
||||
|
||||
var_dump(intlcal_get_skipped_wall_time_option(1));
|
||||
|
||||
--EXPECTF--
|
||||
|
||||
Warning: IntlCalendar::getSkippedWallTimeOption() expects exactly 0 parameters, 1 given in %s on line %d
|
||||
|
||||
Warning: IntlCalendar::getSkippedWallTimeOption(): intlcal_get_skipped_wall_time_option: bad arguments in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: IntlCalendar::getRepeatedWallTimeOption() expects exactly 0 parameters, 1 given in %s on line %d
|
||||
|
||||
Warning: IntlCalendar::getRepeatedWallTimeOption(): intlcal_get_repeated_wall_time_option: bad arguments in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: intlcal_get_skipped_wall_time_option() expects exactly 1 parameter, 2 given in %s on line %d
|
||||
|
||||
Warning: intlcal_get_skipped_wall_time_option(): intlcal_get_skipped_wall_time_option: bad arguments in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: intlcal_get_repeated_wall_time_option() expects exactly 1 parameter, 2 given in %s on line %d
|
||||
|
||||
Warning: intlcal_get_repeated_wall_time_option(): intlcal_get_repeated_wall_time_option: bad arguments in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Catchable fatal error: Argument 1 passed to intlcal_get_skipped_wall_time_option() must be an instance of IntlCalendar, integer given in %s on line %d
|
34
ext/intl/tests/calendar_getTimeZone_basic.phpt
Normal file
34
ext/intl/tests/calendar_getTimeZone_basic.phpt
Normal file
@ -0,0 +1,34 @@
|
||||
--TEST--
|
||||
IntlCalendar::getTimeZone() basic test
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded('intl'))
|
||||
die('skip intl extension not enabled');
|
||||
if (version_compare(INTL_ICU_VERSION, '4.8') < 0)
|
||||
die('skip for ICU 4.8+');
|
||||
--FILE--
|
||||
<?php
|
||||
ini_set("intl.error_level", E_WARNING);
|
||||
ini_set("intl.default_locale", "nl");
|
||||
|
||||
$intlcal = IntlCalendar::createInstance('GMT+00:01');
|
||||
print_r($intlcal->getTimeZone());
|
||||
print_r(intlcal_get_time_zone($intlcal));
|
||||
?>
|
||||
==DONE==
|
||||
--EXPECT--
|
||||
IntlTimeZone Object
|
||||
(
|
||||
[valid] => 1
|
||||
[id] => GMT+00:01
|
||||
[rawOffset] => 60000
|
||||
[currentOffset] => 60000
|
||||
)
|
||||
IntlTimeZone Object
|
||||
(
|
||||
[valid] => 1
|
||||
[id] => GMT+00:01
|
||||
[rawOffset] => 60000
|
||||
[currentOffset] => 60000
|
||||
)
|
||||
==DONE==
|
32
ext/intl/tests/calendar_getTimeZone_error.phpt
Normal file
32
ext/intl/tests/calendar_getTimeZone_error.phpt
Normal file
@ -0,0 +1,32 @@
|
||||
--TEST--
|
||||
IntlCalendar::getTimeZone(): bad arguments
|
||||
--INI--
|
||||
date.timezone=Atlantic/Azores
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded('intl'))
|
||||
die('skip intl extension not enabled');
|
||||
--FILE--
|
||||
<?php
|
||||
ini_set("intl.error_level", E_WARNING);
|
||||
|
||||
$c = new IntlGregorianCalendar(NULL, 'pt_PT');
|
||||
|
||||
var_dump($c->getTimeZone(1));
|
||||
|
||||
var_dump(intlcal_get_time_zone($c, 1));
|
||||
var_dump(intlcal_get_time_zone(1));
|
||||
|
||||
--EXPECTF--
|
||||
|
||||
Warning: IntlCalendar::getTimeZone() expects exactly 0 parameters, 1 given in %s on line %d
|
||||
|
||||
Warning: IntlCalendar::getTimeZone(): intlcal_get_time_zone: bad arguments in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: intlcal_get_time_zone() expects exactly 1 parameter, 2 given in %s on line %d
|
||||
|
||||
Warning: intlcal_get_time_zone(): intlcal_get_time_zone: bad arguments in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Catchable fatal error: Argument 1 passed to intlcal_get_time_zone() must be an instance of IntlCalendar, integer given in %s on line %d
|
29
ext/intl/tests/calendar_getTime_basic.phpt
Normal file
29
ext/intl/tests/calendar_getTime_basic.phpt
Normal file
@ -0,0 +1,29 @@
|
||||
--TEST--
|
||||
IntlCalendar::getTime() basic test
|
||||
--INI--
|
||||
date.timezone=Atlantic/Azores
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded('intl'))
|
||||
die('skip intl extension not enabled');
|
||||
--FILE--
|
||||
<?php
|
||||
ini_set("intl.error_level", E_WARNING);
|
||||
ini_set("intl.default_locale", "nl");
|
||||
|
||||
$intlcal = IntlCalendar::createInstance('UTC');
|
||||
$intlcal->clear();
|
||||
$intlcal->set(IntlCalendar::FIELD_YEAR, 2012);
|
||||
$intlcal->set(IntlCalendar::FIELD_MONTH, 1 /* Feb */);
|
||||
$intlcal->set(IntlCalendar::FIELD_DAY_OF_MONTH, 29);
|
||||
|
||||
$time = strtotime('2012-02-29 00:00:00 +0000');
|
||||
|
||||
var_dump((float)$time*1000, $intlcal->getTime());
|
||||
|
||||
?>
|
||||
==DONE==
|
||||
--EXPECT--
|
||||
float(1330473600000)
|
||||
float(1330473600000)
|
||||
==DONE==
|
31
ext/intl/tests/calendar_getTime_error.phpt
Normal file
31
ext/intl/tests/calendar_getTime_error.phpt
Normal file
@ -0,0 +1,31 @@
|
||||
--TEST--
|
||||
IntlCalendar::getTime(): bad arguments
|
||||
--INI--
|
||||
date.timezone=Atlantic/Azores
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded('intl'))
|
||||
die('skip intl extension not enabled');
|
||||
--FILE--
|
||||
<?php
|
||||
ini_set("intl.error_level", E_WARNING);
|
||||
|
||||
$c = new IntlGregorianCalendar(NULL, 'pt_PT');
|
||||
|
||||
var_dump($c->getTime(1));
|
||||
|
||||
var_dump(intlcal_get_time($c, 1));
|
||||
var_dump(intlcal_get_time(1));
|
||||
--EXPECTF--
|
||||
|
||||
Warning: IntlCalendar::getTime() expects exactly 0 parameters, 1 given in %s on line %d
|
||||
|
||||
Warning: IntlCalendar::getTime(): intlcal_get_time: bad arguments in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: intlcal_get_time() expects exactly 1 parameter, 2 given in %s on line %d
|
||||
|
||||
Warning: intlcal_get_time(): intlcal_get_time: bad arguments in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Catchable fatal error: Argument 1 passed to intlcal_get_time() must be an instance of IntlCalendar, integer given in %s on line %d
|
23
ext/intl/tests/calendar_getType_basic.phpt
Normal file
23
ext/intl/tests/calendar_getType_basic.phpt
Normal file
@ -0,0 +1,23 @@
|
||||
--TEST--
|
||||
IntlCalendar::getType() basic test
|
||||
--INI--
|
||||
date.timezone=Atlantic/Azores
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded('intl'))
|
||||
die('skip intl extension not enabled');
|
||||
--FILE--
|
||||
<?php
|
||||
ini_set("intl.error_level", E_WARNING);
|
||||
ini_set("intl.default_locale", "nl");
|
||||
|
||||
$intlcal = IntlCalendar::createInstance();
|
||||
VAR_DUMP($intlcal->getType());
|
||||
$intlcal = IntlCalendar::createInstance(null, "nl_NL@calendar=hebrew");
|
||||
VAR_DUMP(intlcal_get_type($intlcal));
|
||||
?>
|
||||
==DONE==
|
||||
--EXPECT--
|
||||
string(9) "gregorian"
|
||||
string(6) "hebrew"
|
||||
==DONE==
|
32
ext/intl/tests/calendar_getType_error.phpt
Normal file
32
ext/intl/tests/calendar_getType_error.phpt
Normal file
@ -0,0 +1,32 @@
|
||||
--TEST--
|
||||
IntlCalendar::getType(): bad arguments
|
||||
--INI--
|
||||
date.timezone=Atlantic/Azores
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded('intl'))
|
||||
die('skip intl extension not enabled');
|
||||
--FILE--
|
||||
<?php
|
||||
ini_set("intl.error_level", E_WARNING);
|
||||
|
||||
$c = new IntlGregorianCalendar(NULL, 'pt_PT');
|
||||
|
||||
var_dump($c->getType(1));
|
||||
|
||||
var_dump(intlcal_get_type($c, 1));
|
||||
var_dump(intlcal_get_type(1));
|
||||
|
||||
--EXPECTF--
|
||||
|
||||
Warning: IntlCalendar::getType() expects exactly 0 parameters, 1 given in %s on line %d
|
||||
|
||||
Warning: IntlCalendar::getType(): intlcal_get_type: bad arguments in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: intlcal_get_type() expects exactly 1 parameter, 2 given in %s on line %d
|
||||
|
||||
Warning: intlcal_get_type(): intlcal_get_type: bad arguments in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Catchable fatal error: Argument 1 passed to intlcal_get_type() must be an instance of IntlCalendar, integer given in %s on line %d
|
24
ext/intl/tests/calendar_getWeekendTransition_basic.phpt
Normal file
24
ext/intl/tests/calendar_getWeekendTransition_basic.phpt
Normal file
@ -0,0 +1,24 @@
|
||||
--TEST--
|
||||
IntlCalendar::getWeekendTransition() basic test
|
||||
--INI--
|
||||
date.timezone=Atlantic/Azores
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded('intl'))
|
||||
die('skip intl extension not enabled');
|
||||
if (version_compare(INTL_ICU_VERSION, '4.4') < 0)
|
||||
die('skip for ICU 4.4+');
|
||||
--FILE--
|
||||
<?php
|
||||
ini_set("intl.error_level", E_WARNING);
|
||||
ini_set("intl.default_locale", "nl");
|
||||
|
||||
$intlcal = IntlCalendar::createInstance();
|
||||
var_dump($intlcal->getWeekendTransition(IntlCalendar::DOW_SUNDAY));
|
||||
var_dump(intlcal_get_weekend_transition($intlcal, IntlCalendar::DOW_SUNDAY));
|
||||
?>
|
||||
==DONE==
|
||||
--EXPECT--
|
||||
int(86400000)
|
||||
int(86400000)
|
||||
==DONE==
|
44
ext/intl/tests/calendar_getWeekendTransition_error.phpt
Normal file
44
ext/intl/tests/calendar_getWeekendTransition_error.phpt
Normal file
@ -0,0 +1,44 @@
|
||||
--TEST--
|
||||
IntlCalendar::getWeekendTransition(): bad arguments
|
||||
--INI--
|
||||
date.timezone=Atlantic/Azores
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded('intl'))
|
||||
die('skip intl extension not enabled');
|
||||
if (version_compare(INTL_ICU_VERSION, '4.4') < 0)
|
||||
die('skip for ICU 4.4+');
|
||||
--FILE--
|
||||
<?php
|
||||
ini_set("intl.error_level", E_WARNING);
|
||||
|
||||
$c = new IntlGregorianCalendar(NULL, 'pt_PT');
|
||||
|
||||
var_dump($c->getWeekendTransition());
|
||||
var_dump($c->getWeekendTransition(1, 2));
|
||||
var_dump($c->getWeekendTransition(0));
|
||||
|
||||
var_dump(intlcal_get_weekend_transition($c));
|
||||
var_dump(intlcal_get_weekend_transition(1, 1));
|
||||
|
||||
--EXPECTF--
|
||||
|
||||
Warning: IntlCalendar::getWeekendTransition() expects exactly 1 parameter, 0 given in %s on line %d
|
||||
|
||||
Warning: IntlCalendar::getWeekendTransition(): intlcal_get_weekend_transition: bad arguments in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: IntlCalendar::getWeekendTransition() expects exactly 1 parameter, 2 given in %s on line %d
|
||||
|
||||
Warning: IntlCalendar::getWeekendTransition(): intlcal_get_weekend_transition: bad arguments in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: IntlCalendar::getWeekendTransition(): intlcal_get_weekend_transition: invalid day of week in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: intlcal_get_weekend_transition() expects exactly 2 parameters, 1 given in %s on line %d
|
||||
|
||||
Warning: intlcal_get_weekend_transition(): intlcal_get_weekend_transition: bad arguments in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Catchable fatal error: Argument 1 passed to intlcal_get_weekend_transition() must be an instance of IntlCalendar, integer given in %s on line %d
|
34
ext/intl/tests/calendar_getXMaximum_basic.phpt
Normal file
34
ext/intl/tests/calendar_getXMaximum_basic.phpt
Normal file
@ -0,0 +1,34 @@
|
||||
--TEST--
|
||||
IntlCalendar::getMaximum(), ::getActualMaximum(), ::getLeastMaximum() basic test
|
||||
--INI--
|
||||
date.timezone=Atlantic/Azores
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded('intl'))
|
||||
die('skip intl extension not enabled');
|
||||
--FILE--
|
||||
<?php
|
||||
ini_set("intl.error_level", E_WARNING);
|
||||
ini_set("intl.default_locale", "nl");
|
||||
|
||||
$intlcal = IntlCalendar::createInstance('UTC');
|
||||
$intlcal->setTime(strtotime('2012-02-29 05:06:07 +0000') * 1000);
|
||||
var_dump(
|
||||
$intlcal->getLeastMaximum(IntlCalendar::FIELD_DAY_OF_MONTH),
|
||||
intlcal_get_least_maximum($intlcal, IntlCalendar::FIELD_DAY_OF_MONTH),
|
||||
$intlcal->getActualMaximum(IntlCalendar::FIELD_DAY_OF_MONTH),
|
||||
intlcal_get_actual_maximum($intlcal, IntlCalendar::FIELD_DAY_OF_MONTH),
|
||||
$intlcal->getMaximum(IntlCalendar::FIELD_DAY_OF_MONTH),
|
||||
intlcal_get_maximum($intlcal, IntlCalendar::FIELD_DAY_OF_MONTH)
|
||||
);
|
||||
|
||||
?>
|
||||
==DONE==
|
||||
--EXPECT--
|
||||
int(28)
|
||||
int(28)
|
||||
int(29)
|
||||
int(29)
|
||||
int(31)
|
||||
int(31)
|
||||
==DONE==
|
34
ext/intl/tests/calendar_getXMinimum_basic.phpt
Normal file
34
ext/intl/tests/calendar_getXMinimum_basic.phpt
Normal file
@ -0,0 +1,34 @@
|
||||
--TEST--
|
||||
IntlCalendar::getMinimum(), ::getActualMinimum(), ::getGreatestMinimum() basic test
|
||||
--INI--
|
||||
date.timezone=Atlantic/Azores
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded('intl'))
|
||||
die('skip intl extension not enabled');
|
||||
--FILE--
|
||||
<?php
|
||||
ini_set("intl.error_level", E_WARNING);
|
||||
ini_set("intl.default_locale", "nl");
|
||||
|
||||
$intlcal = IntlCalendar::createInstance('UTC');
|
||||
$intlcal->setTime(strtotime('2012-02-29 05:06:07 +0000') * 1000);
|
||||
var_dump(
|
||||
$intlcal->getGreatestMinimum(IntlCalendar::FIELD_DAY_OF_MONTH),
|
||||
intlcal_get_greatest_minimum($intlcal, IntlCalendar::FIELD_DAY_OF_MONTH),
|
||||
$intlcal->getActualMinimum(IntlCalendar::FIELD_DAY_OF_MONTH),
|
||||
intlcal_get_actual_minimum($intlcal, IntlCalendar::FIELD_DAY_OF_MONTH),
|
||||
$intlcal->getMinimum(IntlCalendar::FIELD_DAY_OF_MONTH),
|
||||
intlcal_get_minimum($intlcal, IntlCalendar::FIELD_DAY_OF_MONTH)
|
||||
);
|
||||
|
||||
?>
|
||||
==DONE==
|
||||
--EXPECT--
|
||||
int(1)
|
||||
int(1)
|
||||
int(1)
|
||||
int(1)
|
||||
int(1)
|
||||
int(1)
|
||||
==DONE==
|
@ -0,0 +1,100 @@
|
||||
--TEST--
|
||||
IntlCalendar::get/Least/Greatest/Minimum/Maximum(): bad arguments
|
||||
--INI--
|
||||
date.timezone=Atlantic/Azores
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded('intl'))
|
||||
die('skip intl extension not enabled');
|
||||
--FILE--
|
||||
<?php
|
||||
ini_set("intl.error_level", E_WARNING);
|
||||
|
||||
$c = new IntlGregorianCalendar(NULL, 'pt_PT');
|
||||
|
||||
var_dump($c->getLeastMaximum());
|
||||
var_dump($c->getMaximum());
|
||||
var_dump($c->getGreatestMinimum());
|
||||
var_dump($c->getMinimum());
|
||||
|
||||
var_dump($c->getLeastMaximum(-1));
|
||||
var_dump($c->getMaximum(-1));
|
||||
var_dump($c->getGreatestMinimum(-1));
|
||||
var_dump($c->getMinimum(-1));
|
||||
|
||||
var_dump(intlcal_get_least_maximum($c, -1));
|
||||
var_dump(intlcal_get_maximum($c, -1));
|
||||
var_dump(intlcal_get_greatest_minimum($c, -1));
|
||||
var_dump(intlcal_get_minimum($c, -1));
|
||||
|
||||
function eh($errno, $errstr) {
|
||||
echo "error: $errno, $errstr\n";
|
||||
}
|
||||
set_error_handler('eh');
|
||||
|
||||
var_dump(intlcal_get_least_maximum(1, 1));
|
||||
var_dump(intlcal_get_maximum(1, 1));
|
||||
var_dump(intlcal_get_greatest_minimum(1, -1));
|
||||
var_dump(intlcal_get_minimum(1, -1));
|
||||
|
||||
--EXPECTF--
|
||||
|
||||
Warning: IntlCalendar::getLeastMaximum() expects exactly 1 parameter, 0 given in %s on line %d
|
||||
|
||||
Warning: IntlCalendar::getLeastMaximum(): intlcal_get_least_maximum: bad arguments in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: IntlCalendar::getMaximum() expects exactly 1 parameter, 0 given in %s on line %d
|
||||
|
||||
Warning: IntlCalendar::getMaximum(): intlcal_get_maximum: bad arguments in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: IntlCalendar::getGreatestMinimum() expects exactly 1 parameter, 0 given in %s on line %d
|
||||
|
||||
Warning: IntlCalendar::getGreatestMinimum(): intlcal_get_greatest_minimum: bad arguments in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: IntlCalendar::getMinimum() expects exactly 1 parameter, 0 given in %s on line %d
|
||||
|
||||
Warning: IntlCalendar::getMinimum(): intlcal_get_minimum: bad arguments in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: IntlCalendar::getLeastMaximum(): intlcal_get_least_maximum: invalid field in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: IntlCalendar::getMaximum(): intlcal_get_maximum: invalid field in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: IntlCalendar::getGreatestMinimum(): intlcal_get_greatest_minimum: invalid field in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: IntlCalendar::getMinimum(): intlcal_get_minimum: invalid field in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: intlcal_get_least_maximum(): intlcal_get_least_maximum: invalid field in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: intlcal_get_maximum(): intlcal_get_maximum: invalid field in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: intlcal_get_greatest_minimum(): intlcal_get_greatest_minimum: invalid field in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: intlcal_get_minimum(): intlcal_get_minimum: invalid field in %s on line %d
|
||||
bool(false)
|
||||
error: 4096, Argument 1 passed to intlcal_get_least_maximum() must be an instance of IntlCalendar, integer given
|
||||
error: 2, intlcal_get_least_maximum() expects parameter 1 to be IntlCalendar, integer given
|
||||
error: 2, intlcal_get_least_maximum(): intlcal_get_least_maximum: bad arguments
|
||||
bool(false)
|
||||
error: 4096, Argument 1 passed to intlcal_get_maximum() must be an instance of IntlCalendar, integer given
|
||||
error: 2, intlcal_get_maximum() expects parameter 1 to be IntlCalendar, integer given
|
||||
error: 2, intlcal_get_maximum(): intlcal_get_maximum: bad arguments
|
||||
bool(false)
|
||||
error: 4096, Argument 1 passed to intlcal_get_greatest_minimum() must be an instance of IntlCalendar, integer given
|
||||
error: 2, intlcal_get_greatest_minimum() expects parameter 1 to be IntlCalendar, integer given
|
||||
error: 2, intlcal_get_greatest_minimum(): intlcal_get_greatest_minimum: bad arguments
|
||||
bool(false)
|
||||
error: 4096, Argument 1 passed to intlcal_get_minimum() must be an instance of IntlCalendar, integer given
|
||||
error: 2, intlcal_get_minimum() expects parameter 1 to be IntlCalendar, integer given
|
||||
error: 2, intlcal_get_minimum(): intlcal_get_minimum: bad arguments
|
||||
bool(false)
|
23
ext/intl/tests/calendar_get_basic.phpt
Normal file
23
ext/intl/tests/calendar_get_basic.phpt
Normal file
@ -0,0 +1,23 @@
|
||||
--TEST--
|
||||
IntlCalendar::get() basic test
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded('intl'))
|
||||
die('skip intl extension not enabled');
|
||||
--FILE--
|
||||
<?php
|
||||
ini_set("intl.error_level", E_WARNING);
|
||||
ini_set("intl.default_locale", "nl");
|
||||
|
||||
$intlcal = IntlCalendar::createInstance('UTC');
|
||||
$intlcal->set(IntlCalendar::FIELD_DAY_OF_MONTH, 4);
|
||||
|
||||
var_dump($intlcal->get(IntlCalendar::FIELD_DAY_OF_MONTH));
|
||||
var_dump(intlcal_get($intlcal, IntlCalendar::FIELD_DAY_OF_MONTH));
|
||||
|
||||
?>
|
||||
==DONE==
|
||||
--EXPECT--
|
||||
int(4)
|
||||
int(4)
|
||||
==DONE==
|
@ -0,0 +1,84 @@
|
||||
--TEST--
|
||||
IntlCalendar::get/getActualMaximum/getActualMinimum(): bad arguments
|
||||
--INI--
|
||||
date.timezone=Atlantic/Azores
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded('intl'))
|
||||
die('skip intl extension not enabled');
|
||||
--FILE--
|
||||
<?php
|
||||
ini_set("intl.error_level", E_WARNING);
|
||||
|
||||
$c = new IntlGregorianCalendar(NULL, 'pt_PT');
|
||||
|
||||
var_dump($c->get());
|
||||
var_dump($c->getActualMaximum());
|
||||
var_dump($c->getActualMinimum());
|
||||
|
||||
var_dump($c->get(-1));
|
||||
var_dump($c->getActualMaximum(-1));
|
||||
var_dump($c->getActualMinimum(-1));
|
||||
|
||||
var_dump($c->get("s"));
|
||||
var_dump($c->getActualMaximum("s"));
|
||||
var_dump($c->getActualMinimum("s"));
|
||||
|
||||
var_dump($c->get(1, 2));
|
||||
var_dump($c->getActualMaximum(1, 2));
|
||||
var_dump($c->getActualMinimum(1, 2));
|
||||
--EXPECTF--
|
||||
|
||||
Warning: IntlCalendar::get() expects exactly 1 parameter, 0 given in %s on line %d
|
||||
|
||||
Warning: IntlCalendar::get(): intlcal_get: bad arguments in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: IntlCalendar::getActualMaximum() expects exactly 1 parameter, 0 given in %s on line %d
|
||||
|
||||
Warning: IntlCalendar::getActualMaximum(): intlcal_get_actual_maximum: bad arguments in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: IntlCalendar::getActualMinimum() expects exactly 1 parameter, 0 given in %s on line %d
|
||||
|
||||
Warning: IntlCalendar::getActualMinimum(): intlcal_get_actual_minimum: bad arguments in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: IntlCalendar::get(): intlcal_get: invalid field in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: IntlCalendar::getActualMaximum(): intlcal_get_actual_maximum: invalid field in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: IntlCalendar::getActualMinimum(): intlcal_get_actual_minimum: invalid field in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: IntlCalendar::get() expects parameter 1 to be long, string given in %s on line %d
|
||||
|
||||
Warning: IntlCalendar::get(): intlcal_get: bad arguments in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: IntlCalendar::getActualMaximum() expects parameter 1 to be long, string given in %s on line %d
|
||||
|
||||
Warning: IntlCalendar::getActualMaximum(): intlcal_get_actual_maximum: bad arguments in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: IntlCalendar::getActualMinimum() expects parameter 1 to be long, string given in %s on line %d
|
||||
|
||||
Warning: IntlCalendar::getActualMinimum(): intlcal_get_actual_minimum: bad arguments in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: IntlCalendar::get() expects exactly 1 parameter, 2 given in %s on line %d
|
||||
|
||||
Warning: IntlCalendar::get(): intlcal_get: bad arguments in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: IntlCalendar::getActualMaximum() expects exactly 1 parameter, 2 given in %s on line %d
|
||||
|
||||
Warning: IntlCalendar::getActualMaximum(): intlcal_get_actual_maximum: bad arguments in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: IntlCalendar::getActualMinimum() expects exactly 1 parameter, 2 given in %s on line %d
|
||||
|
||||
Warning: IntlCalendar::getActualMinimum(): intlcal_get_actual_minimum: bad arguments in %s on line %d
|
||||
bool(false)
|
@ -0,0 +1,71 @@
|
||||
--TEST--
|
||||
IntlCalendar::get/getActualMaximum/getActualMinimum(): bad arguments (procedural)
|
||||
--INI--
|
||||
date.timezone=Atlantic/Azores
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded('intl'))
|
||||
die('skip intl extension not enabled');
|
||||
--FILE--
|
||||
<?php
|
||||
ini_set("intl.error_level", E_WARNING);
|
||||
|
||||
$c = new IntlGregorianCalendar(NULL, 'pt_PT');
|
||||
|
||||
function eh($errno, $errstr) {
|
||||
echo "error: $errno, $errstr\n";
|
||||
}
|
||||
set_error_handler('eh');
|
||||
|
||||
var_dump(intlcal_get($c));
|
||||
var_dump(intlcal_get_actual_maximum($c));
|
||||
var_dump(intlcal_get_actual_minimum($c));
|
||||
|
||||
var_dump(intlcal_get($c, -1));
|
||||
var_dump(intlcal_get_actual_maximum($c, -1));
|
||||
var_dump(intlcal_get_actual_minimum($c, -1));
|
||||
|
||||
var_dump(intlcal_get($c, "s"));
|
||||
var_dump(intlcal_get_actual_maximum($c, "s"));
|
||||
var_dump(intlcal_get_actual_minimum($c, "s"));
|
||||
|
||||
var_dump(intlcal_get(1));
|
||||
var_dump(intlcal_get_actual_maximum(1));
|
||||
var_dump(intlcal_get_actual_minimum(1));
|
||||
--EXPECT--
|
||||
error: 2, intlcal_get() expects exactly 2 parameters, 1 given
|
||||
error: 2, intlcal_get(): intlcal_get: bad arguments
|
||||
bool(false)
|
||||
error: 2, intlcal_get_actual_maximum() expects exactly 2 parameters, 1 given
|
||||
error: 2, intlcal_get_actual_maximum(): intlcal_get_actual_maximum: bad arguments
|
||||
bool(false)
|
||||
error: 2, intlcal_get_actual_minimum() expects exactly 2 parameters, 1 given
|
||||
error: 2, intlcal_get_actual_minimum(): intlcal_get_actual_minimum: bad arguments
|
||||
bool(false)
|
||||
error: 2, intlcal_get(): intlcal_get: invalid field
|
||||
bool(false)
|
||||
error: 2, intlcal_get_actual_maximum(): intlcal_get_actual_maximum: invalid field
|
||||
bool(false)
|
||||
error: 2, intlcal_get_actual_minimum(): intlcal_get_actual_minimum: invalid field
|
||||
bool(false)
|
||||
error: 2, intlcal_get() expects parameter 2 to be long, string given
|
||||
error: 2, intlcal_get(): intlcal_get: bad arguments
|
||||
bool(false)
|
||||
error: 2, intlcal_get_actual_maximum() expects parameter 2 to be long, string given
|
||||
error: 2, intlcal_get_actual_maximum(): intlcal_get_actual_maximum: bad arguments
|
||||
bool(false)
|
||||
error: 2, intlcal_get_actual_minimum() expects parameter 2 to be long, string given
|
||||
error: 2, intlcal_get_actual_minimum(): intlcal_get_actual_minimum: bad arguments
|
||||
bool(false)
|
||||
error: 4096, Argument 1 passed to intlcal_get() must be an instance of IntlCalendar, integer given
|
||||
error: 2, intlcal_get() expects exactly 2 parameters, 1 given
|
||||
error: 2, intlcal_get(): intlcal_get: bad arguments
|
||||
bool(false)
|
||||
error: 4096, Argument 1 passed to intlcal_get_actual_maximum() must be an instance of IntlCalendar, integer given
|
||||
error: 2, intlcal_get_actual_maximum() expects exactly 2 parameters, 1 given
|
||||
error: 2, intlcal_get_actual_maximum(): intlcal_get_actual_maximum: bad arguments
|
||||
bool(false)
|
||||
error: 4096, Argument 1 passed to intlcal_get_actual_minimum() must be an instance of IntlCalendar, integer given
|
||||
error: 2, intlcal_get_actual_minimum() expects exactly 2 parameters, 1 given
|
||||
error: 2, intlcal_get_actual_minimum(): intlcal_get_actual_minimum: bad arguments
|
||||
bool(false)
|
@ -0,0 +1,49 @@
|
||||
--TEST--
|
||||
IntlCalendar::get/setRepeatedWallTimeOption(): basic test
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded('intl'))
|
||||
die('skip intl extension not enabled');
|
||||
if (version_compare(INTL_ICU_VERSION, '49') < 0)
|
||||
die('skip for ICU 49+');
|
||||
--FILE--
|
||||
|
||||
<?php
|
||||
ini_set("intl.error_level", E_WARNING);
|
||||
ini_set("intl.default_locale", "nl");
|
||||
|
||||
date_default_timezone_set('Europe/Amsterdam');
|
||||
|
||||
//28 October 2012, transition from DST
|
||||
$intlcal = new IntlGregorianCalendar(2012, 9, 28, 0, 0, 0);
|
||||
var_dump($intlcal->setRepeatedWallTimeOption(IntlCalendar::WALLTIME_LAST));
|
||||
var_dump($intlcal->getRepeatedWallTimeOption());
|
||||
$intlcal->set(IntlCalendar::FIELD_HOUR_OF_DAY, 2);
|
||||
$intlcal->set(IntlCalendar::FIELD_MINUTE, 30);
|
||||
var_dump(
|
||||
strtotime('2012-10-28 02:30:00 +0100'),
|
||||
(int)($intlcal->getTime() /1000)
|
||||
);
|
||||
|
||||
var_dump(intlcal_set_repeated_wall_time_option($intlcal, IntlCalendar::WALLTIME_FIRST));
|
||||
var_dump(intlcal_get_repeated_wall_time_option($intlcal));
|
||||
$intlcal->set(IntlCalendar::FIELD_HOUR_OF_DAY, 2);
|
||||
$intlcal->set(IntlCalendar::FIELD_MINUTE, 30);
|
||||
var_dump(
|
||||
strtotime('2012-10-28 02:30:00 +0200'),
|
||||
(int)($intlcal->getTime() /1000)
|
||||
);
|
||||
|
||||
?>
|
||||
==DONE==
|
||||
--EXPECT--
|
||||
|
||||
bool(true)
|
||||
int(0)
|
||||
int(1351387800)
|
||||
int(1351387800)
|
||||
bool(true)
|
||||
int(1)
|
||||
int(1351384200)
|
||||
int(1351384200)
|
||||
==DONE==
|
@ -0,0 +1,67 @@
|
||||
--TEST--
|
||||
IntlCalendar::get/setSkippedWallTimeOption(): basic test
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded('intl'))
|
||||
die('skip intl extension not enabled');
|
||||
if (version_compare(INTL_ICU_VERSION, '49') < 0)
|
||||
die('skip for ICU 49+');
|
||||
--FILE--
|
||||
|
||||
<?php
|
||||
ini_set("intl.error_level", E_WARNING);
|
||||
ini_set("intl.default_locale", "nl");
|
||||
|
||||
date_default_timezone_set('Europe/Amsterdam');
|
||||
|
||||
//25 March 2012, transition to DST
|
||||
$intlcal = new IntlGregorianCalendar(2012, 2, 25, 0, 0, 0);
|
||||
var_dump($intlcal->getSkippedWallTimeOption());
|
||||
$intlcal->set(IntlCalendar::FIELD_HOUR_OF_DAY, 2);
|
||||
$intlcal->set(IntlCalendar::FIELD_MINUTE, 30);
|
||||
echo "Should be 3h30\n";
|
||||
var_dump(
|
||||
$intlcal->get(IntlCalendar::FIELD_HOUR_OF_DAY),
|
||||
$intlcal->get(IntlCalendar::FIELD_MINUTE)
|
||||
);
|
||||
|
||||
var_dump($intlcal->setSkippedWallTimeOption(IntlCalendar::WALLTIME_FIRST));
|
||||
var_dump(intlcal_get_skipped_wall_time_option($intlcal));
|
||||
$intlcal->set(IntlCalendar::FIELD_HOUR_OF_DAY, 2);
|
||||
$intlcal->set(IntlCalendar::FIELD_MINUTE, 30);
|
||||
echo "Should be 1h30\n";
|
||||
var_dump(
|
||||
$intlcal->get(IntlCalendar::FIELD_HOUR_OF_DAY),
|
||||
$intlcal->get(IntlCalendar::FIELD_MINUTE)
|
||||
);
|
||||
|
||||
var_dump(intlcal_set_skipped_wall_time_option($intlcal, IntlCalendar::WALLTIME_NEXT_VALID));
|
||||
var_dump($intlcal->getSkippedWallTimeOption());
|
||||
$intlcal->set(IntlCalendar::FIELD_HOUR_OF_DAY, 2);
|
||||
$intlcal->set(IntlCalendar::FIELD_MINUTE, 30);
|
||||
echo "Should be 3h00\n";
|
||||
var_dump(
|
||||
$intlcal->get(IntlCalendar::FIELD_HOUR_OF_DAY),
|
||||
$intlcal->get(IntlCalendar::FIELD_MINUTE)
|
||||
);
|
||||
|
||||
|
||||
?>
|
||||
==DONE==
|
||||
--EXPECT--
|
||||
|
||||
int(0)
|
||||
Should be 3h30
|
||||
int(3)
|
||||
int(30)
|
||||
bool(true)
|
||||
int(1)
|
||||
Should be 1h30
|
||||
int(1)
|
||||
int(30)
|
||||
bool(true)
|
||||
int(2)
|
||||
Should be 3h00
|
||||
int(3)
|
||||
int(0)
|
||||
==DONE==
|
24
ext/intl/tests/calendar_inDaylightTime_basic.phpt
Normal file
24
ext/intl/tests/calendar_inDaylightTime_basic.phpt
Normal file
@ -0,0 +1,24 @@
|
||||
--TEST--
|
||||
IntlCalendar::inDaylightTime() basic test
|
||||
--INI--
|
||||
date.timezone=Atlantic/Azores
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded('intl'))
|
||||
die('skip intl extension not enabled');
|
||||
--FILE--
|
||||
<?php
|
||||
ini_set("intl.error_level", E_WARNING);
|
||||
ini_set("intl.default_locale", "nl");
|
||||
|
||||
$intlcal = IntlCalendar::createInstance('Europe/Amsterdam');
|
||||
$intlcal->setTime(strtotime('2012-01-01') * 1000);
|
||||
var_dump($intlcal->inDaylightTime());
|
||||
$intlcal->setTime(strtotime('2012-04-01') * 1000);
|
||||
var_dump(intlcal_in_daylight_time($intlcal));
|
||||
?>
|
||||
==DONE==
|
||||
--EXPECT--
|
||||
bool(false)
|
||||
bool(true)
|
||||
==DONE==
|
32
ext/intl/tests/calendar_inDaylightTime_error.phpt
Normal file
32
ext/intl/tests/calendar_inDaylightTime_error.phpt
Normal file
@ -0,0 +1,32 @@
|
||||
--TEST--
|
||||
IntlCalendar::inDaylightTime(): bad arguments
|
||||
--INI--
|
||||
date.timezone=Atlantic/Azores
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded('intl'))
|
||||
die('skip intl extension not enabled');
|
||||
--FILE--
|
||||
<?php
|
||||
ini_set("intl.error_level", E_WARNING);
|
||||
|
||||
$c = new IntlGregorianCalendar(NULL, 'pt_PT');
|
||||
|
||||
var_dump($c->inDaylightTime(1));
|
||||
|
||||
var_dump(intlcal_in_daylight_time($c, 1));
|
||||
var_dump(intlcal_in_daylight_time(1));
|
||||
|
||||
--EXPECTF--
|
||||
|
||||
Warning: IntlCalendar::inDaylightTime() expects exactly 0 parameters, 1 given in %s on line %d
|
||||
|
||||
Warning: IntlCalendar::inDaylightTime(): intlcal_in_daylight_time: bad arguments in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: intlcal_in_daylight_time() expects exactly 1 parameter, 2 given in %s on line %d
|
||||
|
||||
Warning: intlcal_in_daylight_time(): intlcal_in_daylight_time: bad arguments in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Catchable fatal error: Argument 1 passed to intlcal_in_daylight_time() must be an instance of IntlCalendar, integer given in %s on line %d
|
40
ext/intl/tests/calendar_isEquivalentTo_basic.phpt
Normal file
40
ext/intl/tests/calendar_isEquivalentTo_basic.phpt
Normal file
@ -0,0 +1,40 @@
|
||||
--TEST--
|
||||
IntlCalendar::isEquivalentTo() basic test
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded('intl'))
|
||||
die('skip intl extension not enabled');
|
||||
--FILE--
|
||||
<?php
|
||||
ini_set("intl.error_level", E_WARNING);
|
||||
ini_set("intl.default_locale", "nl");
|
||||
|
||||
$intlcal1 = IntlCalendar::createInstance('Europe/Amsterdam');
|
||||
$intlcal2 = IntlCalendar::createInstance('Europe/Lisbon');
|
||||
$intlcal3 = IntlCalendar::createInstance('Europe/Amsterdam', "nl_NL@calendar=islamic");
|
||||
$intlcal4 = IntlCalendar::createInstance('Europe/Amsterdam');
|
||||
$intlcal4->roll(IntlCalendar::FIELD_MONTH, true);
|
||||
|
||||
var_dump(
|
||||
"1 - 1",
|
||||
$intlcal1->isEquivalentTo($intlcal1),
|
||||
"1 - 2",
|
||||
$intlcal1->isEquivalentTo($intlcal2),
|
||||
"1 - 3",
|
||||
$intlcal1->isEquivalentTo($intlcal3),
|
||||
"1 - 4",
|
||||
$intlcal1->isEquivalentTo($intlcal4)
|
||||
);
|
||||
|
||||
?>
|
||||
==DONE==
|
||||
--EXPECT--
|
||||
string(5) "1 - 1"
|
||||
bool(true)
|
||||
string(5) "1 - 2"
|
||||
bool(false)
|
||||
string(5) "1 - 3"
|
||||
bool(false)
|
||||
string(5) "1 - 4"
|
||||
bool(true)
|
||||
==DONE==
|
50
ext/intl/tests/calendar_isEquivalentTo_error.phpt
Normal file
50
ext/intl/tests/calendar_isEquivalentTo_error.phpt
Normal file
@ -0,0 +1,50 @@
|
||||
--TEST--
|
||||
IntlCalendar::isEquivalentTo(): bad arguments
|
||||
--INI--
|
||||
date.timezone=Atlantic/Azores
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded('intl'))
|
||||
die('skip intl extension not enabled');
|
||||
--FILE--
|
||||
<?php
|
||||
ini_set("intl.error_level", E_WARNING);
|
||||
|
||||
$c = new IntlGregorianCalendar(NULL, 'pt_PT');
|
||||
|
||||
function eh($errno, $errstr) {
|
||||
echo "error: $errno, $errstr\n";
|
||||
}
|
||||
set_error_handler('eh');
|
||||
|
||||
var_dump($c->isEquivalentTo(0));
|
||||
var_dump($c->isEquivalentTo($c, 1));
|
||||
var_dump($c->isEquivalentTo(1));
|
||||
|
||||
var_dump(intlcal_is_equivalent_to($c));
|
||||
var_dump(intlcal_is_equivalent_to($c, 1));
|
||||
var_dump(intlcal_is_equivalent_to(1, $c));
|
||||
|
||||
--EXPECT--
|
||||
error: 4096, Argument 1 passed to IntlCalendar::isEquivalentTo() must be an instance of IntlCalendar, integer given
|
||||
error: 2, IntlCalendar::isEquivalentTo() expects parameter 1 to be IntlCalendar, integer given
|
||||
error: 2, IntlCalendar::isEquivalentTo(): intlcal_is_equivalent_to: bad arguments
|
||||
bool(false)
|
||||
error: 2, IntlCalendar::isEquivalentTo() expects exactly 1 parameter, 2 given
|
||||
error: 2, IntlCalendar::isEquivalentTo(): intlcal_is_equivalent_to: bad arguments
|
||||
bool(false)
|
||||
error: 4096, Argument 1 passed to IntlCalendar::isEquivalentTo() must be an instance of IntlCalendar, integer given
|
||||
error: 2, IntlCalendar::isEquivalentTo() expects parameter 1 to be IntlCalendar, integer given
|
||||
error: 2, IntlCalendar::isEquivalentTo(): intlcal_is_equivalent_to: bad arguments
|
||||
bool(false)
|
||||
error: 2, intlcal_is_equivalent_to() expects exactly 2 parameters, 1 given
|
||||
error: 2, intlcal_is_equivalent_to(): intlcal_is_equivalent_to: bad arguments
|
||||
bool(false)
|
||||
error: 4096, Argument 2 passed to intlcal_is_equivalent_to() must be an instance of IntlCalendar, integer given
|
||||
error: 2, intlcal_is_equivalent_to() expects parameter 2 to be IntlCalendar, integer given
|
||||
error: 2, intlcal_is_equivalent_to(): intlcal_is_equivalent_to: bad arguments
|
||||
bool(false)
|
||||
error: 4096, Argument 1 passed to intlcal_is_equivalent_to() must be an instance of IntlCalendar, integer given
|
||||
error: 2, intlcal_is_equivalent_to() expects parameter 1 to be IntlCalendar, integer given
|
||||
error: 2, intlcal_is_equivalent_to(): intlcal_is_equivalent_to: bad arguments
|
||||
bool(false)
|
32
ext/intl/tests/calendar_isLenient_error.phpt
Normal file
32
ext/intl/tests/calendar_isLenient_error.phpt
Normal file
@ -0,0 +1,32 @@
|
||||
--TEST--
|
||||
IntlCalendar::isLenient(): bad arguments
|
||||
--INI--
|
||||
date.timezone=Atlantic/Azores
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded('intl'))
|
||||
die('skip intl extension not enabled');
|
||||
--FILE--
|
||||
<?php
|
||||
ini_set("intl.error_level", E_WARNING);
|
||||
|
||||
$c = new IntlGregorianCalendar(NULL, 'pt_PT');
|
||||
|
||||
var_dump($c->isLenient(1));
|
||||
|
||||
var_dump(intlcal_is_lenient($c, 1));
|
||||
var_dump(intlcal_is_lenient(1));
|
||||
|
||||
--EXPECTF--
|
||||
|
||||
Warning: IntlCalendar::isLenient() expects exactly 0 parameters, 1 given in %s on line %d
|
||||
|
||||
Warning: IntlCalendar::isLenient(): intlcal_is_lenient: bad arguments in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: intlcal_is_lenient() expects exactly 1 parameter, 2 given in %s on line %d
|
||||
|
||||
Warning: intlcal_is_lenient(): intlcal_is_lenient: bad arguments in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Catchable fatal error: Argument 1 passed to intlcal_is_lenient() must be an instance of IntlCalendar, integer given in %s on line %d
|
24
ext/intl/tests/calendar_isSet_basic.phpt
Normal file
24
ext/intl/tests/calendar_isSet_basic.phpt
Normal file
@ -0,0 +1,24 @@
|
||||
--TEST--
|
||||
IntlCalendar::isSet() basic test
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded('intl'))
|
||||
die('skip intl extension not enabled');
|
||||
--FILE--
|
||||
<?php
|
||||
ini_set("intl.error_level", E_WARNING);
|
||||
ini_set("intl.default_locale", "nl");
|
||||
|
||||
$intlcal = IntlCalendar::createInstance('UTC');
|
||||
var_dump($intlcal->isSet(IntlCalendar::FIELD_MINUTE));
|
||||
$intlcal->clear(IntlCalendar::FIELD_MINUTE);
|
||||
var_dump($intlcal->isSet(IntlCalendar::FIELD_MINUTE));
|
||||
$intlcal->set(IntlCalendar::FIELD_MINUTE, 0);
|
||||
var_dump(intlcal_is_set($intlcal, IntlCalendar::FIELD_MINUTE));
|
||||
?>
|
||||
==DONE==
|
||||
--EXPECT--
|
||||
bool(true)
|
||||
bool(false)
|
||||
bool(true)
|
||||
==DONE==
|
42
ext/intl/tests/calendar_isSet_error.phpt
Normal file
42
ext/intl/tests/calendar_isSet_error.phpt
Normal file
@ -0,0 +1,42 @@
|
||||
--TEST--
|
||||
IntlCalendar::isSet(): bad arguments
|
||||
--INI--
|
||||
date.timezone=Atlantic/Azores
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded('intl'))
|
||||
die('skip intl extension not enabled');
|
||||
--FILE--
|
||||
<?php
|
||||
ini_set("intl.error_level", E_WARNING);
|
||||
|
||||
$c = new IntlGregorianCalendar(NULL, 'pt_PT');
|
||||
|
||||
var_dump($c->isSet());
|
||||
var_dump($c->isSet(1, 2));
|
||||
var_dump($c->isSet(-1));
|
||||
|
||||
var_dump(intlcal_is_set($c));
|
||||
var_dump(intlcal_is_set(1, 2));
|
||||
|
||||
--EXPECTF--
|
||||
|
||||
Warning: IntlCalendar::isSet() expects exactly 1 parameter, 0 given in %s on line %d
|
||||
|
||||
Warning: IntlCalendar::isSet(): intlcal_is_set: bad arguments in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: IntlCalendar::isSet() expects exactly 1 parameter, 2 given in %s on line %d
|
||||
|
||||
Warning: IntlCalendar::isSet(): intlcal_is_set: bad arguments in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: IntlCalendar::isSet(): intlcal_is_set: invalid field in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: intlcal_is_set() expects exactly 2 parameters, 1 given in %s on line %d
|
||||
|
||||
Warning: intlcal_is_set(): intlcal_is_set: bad arguments in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Catchable fatal error: Argument 1 passed to intlcal_is_set() must be an instance of IntlCalendar, integer given in %s on line %d
|
26
ext/intl/tests/calendar_isWeekend_basic.phpt
Normal file
26
ext/intl/tests/calendar_isWeekend_basic.phpt
Normal file
@ -0,0 +1,26 @@
|
||||
--TEST--
|
||||
IntlCalendar::isWeekend basic test
|
||||
--INI--
|
||||
date.timezone=Atlantic/Azores
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded('intl'))
|
||||
die('skip intl extension not enabled');
|
||||
if (version_compare(INTL_ICU_VERSION, '4.4') < 0)
|
||||
die('skip for ICU 4.4+');
|
||||
--FILE--
|
||||
<?php
|
||||
ini_set("intl.error_level", E_WARNING);
|
||||
ini_set("intl.default_locale", "nl");
|
||||
|
||||
$intlcal = IntlCalendar::createInstance('UTC');
|
||||
var_dump($intlcal->isWeekend(strtotime('2012-02-29 12:00:00 +0000') * 1000));
|
||||
var_dump(intlcal_is_weekend($intlcal, strtotime('2012-02-29 12:00:00 +0000') * 1000));
|
||||
var_dump($intlcal->isWeekend(strtotime('2012-03-11 12:00:00 +0000') * 1000));
|
||||
?>
|
||||
==DONE==
|
||||
--EXPECT--
|
||||
bool(false)
|
||||
bool(false)
|
||||
bool(true)
|
||||
==DONE==
|
38
ext/intl/tests/calendar_isWeekend_error.phpt
Normal file
38
ext/intl/tests/calendar_isWeekend_error.phpt
Normal file
@ -0,0 +1,38 @@
|
||||
--TEST--
|
||||
IntlCalendar::isWeekend(): bad arguments
|
||||
--INI--
|
||||
date.timezone=Atlantic/Azores
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded('intl'))
|
||||
die('skip intl extension not enabled');
|
||||
if (version_compare(INTL_ICU_VERSION, '4.4') < 0)
|
||||
die('skip for ICU 4.4+');
|
||||
--FILE--
|
||||
<?php
|
||||
ini_set("intl.error_level", E_WARNING);
|
||||
|
||||
$c = new IntlGregorianCalendar(NULL, 'pt_PT');
|
||||
|
||||
var_dump($c->isWeekend(1, 2));
|
||||
var_dump($c->isWeekend("jhhk"));
|
||||
|
||||
var_dump(intlcal_is_weekend($c, "jj"));
|
||||
var_dump(intlcal_is_weekend(1));
|
||||
|
||||
--EXPECTF--
|
||||
|
||||
Warning: IntlCalendar::isWeekend(): intlcal_is_weekend: bad arguments in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: IntlCalendar::isWeekend() expects parameter 1 to be double, string given in %s on line %d
|
||||
|
||||
Warning: IntlCalendar::isWeekend(): intlcal_is_weekend: bad arguments in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: intlcal_is_weekend() expects parameter 2 to be double, string given in %s on line %d
|
||||
|
||||
Warning: intlcal_is_weekend(): intlcal_is_weekend: bad arguments in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Catchable fatal error: Argument 1 passed to intlcal_is_weekend() must be an instance of IntlCalendar, integer given in %s on line %d
|
28
ext/intl/tests/calendar_is_set_lenient_basic.phpt
Normal file
28
ext/intl/tests/calendar_is_set_lenient_basic.phpt
Normal file
@ -0,0 +1,28 @@
|
||||
--TEST--
|
||||
IntlCalendar::isLenient(), ::setLenient() basic test
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded('intl'))
|
||||
die('skip intl extension not enabled');
|
||||
--FILE--
|
||||
<?php
|
||||
ini_set("intl.error_level", E_WARNING);
|
||||
ini_set("intl.default_locale", "nl");
|
||||
|
||||
$intlcal1 = IntlCalendar::createInstance('UTC');
|
||||
var_dump($intlcal1->isLenient());
|
||||
var_dump(intlcal_is_lenient($intlcal1));
|
||||
var_dump($intlcal1->setLenient(false));
|
||||
var_dump($intlcal1->isLenient());
|
||||
var_dump(intlcal_set_lenient($intlcal1, true));
|
||||
var_dump($intlcal1->isLenient());
|
||||
?>
|
||||
==DONE==
|
||||
--EXPECT--
|
||||
bool(true)
|
||||
bool(true)
|
||||
bool(true)
|
||||
bool(false)
|
||||
bool(true)
|
||||
bool(true)
|
||||
==DONE==
|
34
ext/intl/tests/calendar_roll_basic.phpt
Normal file
34
ext/intl/tests/calendar_roll_basic.phpt
Normal file
@ -0,0 +1,34 @@
|
||||
--TEST--
|
||||
IntlCalendar::roll() basic test
|
||||
--INI--
|
||||
date.timezone=Atlantic/Azores
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded('intl'))
|
||||
die('skip intl extension not enabled');
|
||||
--FILE--
|
||||
<?php
|
||||
ini_set("intl.error_level", E_WARNING);
|
||||
ini_set("intl.default_locale", "nl");
|
||||
|
||||
$intlcal = new IntlGregorianCalendar(2012, 1, 28);
|
||||
var_dump($intlcal->roll(IntlCalendar::FIELD_DAY_OF_MONTH, 2));
|
||||
var_dump($intlcal->get(IntlCalendar::FIELD_MONTH)); //1 (Feb)
|
||||
var_dump($intlcal->get(IntlCalendar::FIELD_DAY_OF_MONTH)); //1
|
||||
|
||||
$intlcal = new IntlGregorianCalendar(2012, 1, 28);
|
||||
var_dump(intlcal_roll($intlcal, IntlCalendar::FIELD_DAY_OF_MONTH, 2));
|
||||
var_dump($intlcal->get(IntlCalendar::FIELD_MONTH)); //1 (Feb)
|
||||
var_dump($intlcal->get(IntlCalendar::FIELD_DAY_OF_MONTH)); //1
|
||||
|
||||
|
||||
?>
|
||||
==DONE==
|
||||
--EXPECT--
|
||||
bool(true)
|
||||
int(1)
|
||||
int(1)
|
||||
bool(true)
|
||||
int(1)
|
||||
int(1)
|
||||
==DONE==
|
37
ext/intl/tests/calendar_roll_error.phpt
Normal file
37
ext/intl/tests/calendar_roll_error.phpt
Normal file
@ -0,0 +1,37 @@
|
||||
--TEST--
|
||||
IntlCalendar::roll(): bad arguments
|
||||
--INI--
|
||||
date.timezone=Atlantic/Azores
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded('intl'))
|
||||
die('skip intl extension not enabled');
|
||||
--FILE--
|
||||
<?php
|
||||
ini_set("intl.error_level", E_WARNING);
|
||||
|
||||
$c = new IntlGregorianCalendar(NULL, 'pt_PT');
|
||||
|
||||
var_dump($c->roll(1, 2, 3));
|
||||
var_dump($c->roll(-1, 2));
|
||||
var_dump($c->roll(1));
|
||||
|
||||
var_dump(intlcal_roll($c, 1, 2, 3));
|
||||
var_dump(intlcal_roll(1, 2, 3));
|
||||
--EXPECTF--
|
||||
|
||||
Warning: IntlCalendar::roll(): intlcal_set: too many arguments in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: IntlCalendar::roll(): intlcal_roll: invalid field in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: IntlCalendar::roll() expects exactly 2 parameters, 1 given in %s on line %d
|
||||
|
||||
Warning: IntlCalendar::roll(): intlcal_roll: bad arguments in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: intlcal_roll(): intlcal_set: too many arguments in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Catchable fatal error: Argument 1 passed to intlcal_roll() must be an instance of IntlCalendar, integer given in %s on line %d
|
32
ext/intl/tests/calendar_roll_variation1.phpt
Normal file
32
ext/intl/tests/calendar_roll_variation1.phpt
Normal file
@ -0,0 +1,32 @@
|
||||
--TEST--
|
||||
IntlCalendar::roll() bool argument variation
|
||||
--INI--
|
||||
date.timezone=Atlantic/Azores
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded('intl'))
|
||||
die('skip intl extension not enabled');
|
||||
--FILE--
|
||||
<?php
|
||||
ini_set("intl.error_level", E_WARNING);
|
||||
ini_set("intl.default_locale", "nl");
|
||||
|
||||
$intlcal = new IntlGregorianCalendar(2012, 1, 28);
|
||||
var_dump($intlcal->roll(IntlCalendar::FIELD_DAY_OF_MONTH, true));
|
||||
var_dump($intlcal->get(IntlCalendar::FIELD_MONTH)); //1 (Feb)
|
||||
var_dump($intlcal->get(IntlCalendar::FIELD_DAY_OF_MONTH)); //29
|
||||
|
||||
var_dump(intlcal_roll($intlcal, IntlCalendar::FIELD_DAY_OF_MONTH, false));
|
||||
var_dump($intlcal->get(IntlCalendar::FIELD_MONTH)); //1 (Feb)
|
||||
var_dump($intlcal->get(IntlCalendar::FIELD_DAY_OF_MONTH)); //28
|
||||
|
||||
?>
|
||||
==DONE==
|
||||
--EXPECT--
|
||||
bool(true)
|
||||
int(1)
|
||||
int(29)
|
||||
bool(true)
|
||||
int(1)
|
||||
int(28)
|
||||
==DONE==
|
28
ext/intl/tests/calendar_setFirstDayOfWeek_basic.phpt
Normal file
28
ext/intl/tests/calendar_setFirstDayOfWeek_basic.phpt
Normal file
@ -0,0 +1,28 @@
|
||||
--TEST--
|
||||
IntlCalendar::setFirstDayOfWeek() basic test
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded('intl'))
|
||||
die('skip intl extension not enabled');
|
||||
--FILE--
|
||||
<?php
|
||||
ini_set("intl.error_level", E_WARNING);
|
||||
ini_set("intl.default_locale", "nl");
|
||||
|
||||
$intlcal = IntlCalendar::createInstance('UTC');
|
||||
var_dump(
|
||||
IntlCalendar::DOW_TUESDAY,
|
||||
$intlcal->setFirstDayOfWeek(IntlCalendar::DOW_TUESDAY),
|
||||
$intlcal->getFirstDayOfWeek(),
|
||||
intlcal_set_first_day_of_week($intlcal, IntlCalendar::DOW_WEDNESDAY),
|
||||
$intlcal->getFirstDayOfWeek()
|
||||
);
|
||||
?>
|
||||
==DONE==
|
||||
--EXPECT--
|
||||
int(3)
|
||||
bool(true)
|
||||
int(3)
|
||||
bool(true)
|
||||
int(4)
|
||||
==DONE==
|
40
ext/intl/tests/calendar_setFirstDayOfWeek_error.phpt
Normal file
40
ext/intl/tests/calendar_setFirstDayOfWeek_error.phpt
Normal file
@ -0,0 +1,40 @@
|
||||
--TEST--
|
||||
IntlCalendar::setFirstDayOfWeek(): bad arguments
|
||||
--INI--
|
||||
date.timezone=Atlantic/Azores
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded('intl'))
|
||||
die('skip intl extension not enabled');
|
||||
--FILE--
|
||||
<?php
|
||||
ini_set("intl.error_level", E_WARNING);
|
||||
|
||||
$c = new IntlGregorianCalendar(NULL, 'pt_PT');
|
||||
|
||||
var_dump($c->setFirstDayOfWeek());
|
||||
var_dump($c->setFirstDayOfWeek(1, 2));
|
||||
var_dump($c->setFirstDayOfWeek(0));
|
||||
|
||||
var_dump(intlcal_set_first_day_of_week($c, 0));
|
||||
var_dump(intlcal_set_first_day_of_week(1, 2));
|
||||
|
||||
--EXPECTF--
|
||||
|
||||
Warning: IntlCalendar::setFirstDayOfWeek() expects exactly 1 parameter, 0 given in %s on line %d
|
||||
|
||||
Warning: IntlCalendar::setFirstDayOfWeek(): intlcal_set_first_day_of_week: bad arguments in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: IntlCalendar::setFirstDayOfWeek() expects exactly 1 parameter, 2 given in %s on line %d
|
||||
|
||||
Warning: IntlCalendar::setFirstDayOfWeek(): intlcal_set_first_day_of_week: bad arguments in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: IntlCalendar::setFirstDayOfWeek(): intlcal_set_first_day_of_week: invalid day of week in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: intlcal_set_first_day_of_week(): intlcal_set_first_day_of_week: invalid day of week in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Catchable fatal error: Argument 1 passed to intlcal_set_first_day_of_week() must be an instance of IntlCalendar, integer given in %s on line %d
|
44
ext/intl/tests/calendar_setLenient_error.phpt
Normal file
44
ext/intl/tests/calendar_setLenient_error.phpt
Normal file
@ -0,0 +1,44 @@
|
||||
--TEST--
|
||||
IntlCalendar::setLenient(): bad arguments
|
||||
--INI--
|
||||
date.timezone=Atlantic/Azores
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded('intl'))
|
||||
die('skip intl extension not enabled');
|
||||
--FILE--
|
||||
<?php
|
||||
ini_set("intl.error_level", E_WARNING);
|
||||
|
||||
$c = new IntlGregorianCalendar(NULL, 'pt_PT');
|
||||
|
||||
var_dump($c->setLenient());
|
||||
var_dump($c->setLenient(array()));
|
||||
var_dump($c->setLenient(1, 2));
|
||||
|
||||
var_dump(intlcal_set_lenient($c, array()));
|
||||
var_dump(intlcal_set_lenient(1, false));
|
||||
|
||||
--EXPECTF--
|
||||
|
||||
Warning: IntlCalendar::setLenient() expects exactly 1 parameter, 0 given in %s on line %d
|
||||
|
||||
Warning: IntlCalendar::setLenient(): intlcal_set_lenient: bad arguments in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: IntlCalendar::setLenient() expects parameter 1 to be boolean, array given in %s on line %d
|
||||
|
||||
Warning: IntlCalendar::setLenient(): intlcal_set_lenient: bad arguments in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: IntlCalendar::setLenient() expects exactly 1 parameter, 2 given in %s on line %d
|
||||
|
||||
Warning: IntlCalendar::setLenient(): intlcal_set_lenient: bad arguments in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: intlcal_set_lenient() expects parameter 2 to be boolean, array given in %s on line %d
|
||||
|
||||
Warning: intlcal_set_lenient(): intlcal_set_lenient: bad arguments in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Catchable fatal error: Argument 1 passed to intlcal_set_lenient() must be an instance of IntlCalendar, integer given in %s on line %d
|
@ -0,0 +1,82 @@
|
||||
--TEST--
|
||||
IntlCalendar::setSkipped/RepeatedWallTimeOption(): bad arguments
|
||||
--INI--
|
||||
date.timezone=Atlantic/Azores
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded('intl'))
|
||||
die('skip intl extension not enabled');
|
||||
if (version_compare(INTL_ICU_VERSION, '49') < 0)
|
||||
die('skip for ICU 49+');
|
||||
--FILE--
|
||||
<?php
|
||||
ini_set("intl.error_level", E_WARNING);
|
||||
|
||||
$c = new IntlGregorianCalendar(NULL, 'pt_PT');
|
||||
|
||||
var_dump($c->setSkippedWallTimeOption());
|
||||
var_dump($c->setRepeatedWallTimeOption());
|
||||
|
||||
var_dump($c->setSkippedWallTimeOption(1, 2));
|
||||
var_dump($c->setRepeatedWallTimeOption(1, 2));
|
||||
|
||||
var_dump($c->setSkippedWallTimeOption(array()));
|
||||
var_dump($c->setRepeatedWallTimeOption(array()));
|
||||
|
||||
var_dump($c->setSkippedWallTimeOption(3));
|
||||
var_dump($c->setRepeatedWallTimeOption(2));
|
||||
|
||||
var_dump(intlcal_set_skipped_wall_time_option($c));
|
||||
var_dump(intlcal_set_repeated_wall_time_option($c));
|
||||
|
||||
var_dump(intlcal_set_repeated_wall_time_option(1, 1));
|
||||
|
||||
--EXPECTF--
|
||||
|
||||
Warning: IntlCalendar::setSkippedWallTimeOption() expects exactly 1 parameter, 0 given in %s on line %d
|
||||
|
||||
Warning: IntlCalendar::setSkippedWallTimeOption(): intlcal_set_skipped_wall_time_option: bad arguments in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: IntlCalendar::setRepeatedWallTimeOption() expects exactly 1 parameter, 0 given in %s on line %d
|
||||
|
||||
Warning: IntlCalendar::setRepeatedWallTimeOption(): intlcal_set_repeated_wall_time_option: bad arguments in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: IntlCalendar::setSkippedWallTimeOption() expects exactly 1 parameter, 2 given in %s on line %d
|
||||
|
||||
Warning: IntlCalendar::setSkippedWallTimeOption(): intlcal_set_skipped_wall_time_option: bad arguments in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: IntlCalendar::setRepeatedWallTimeOption() expects exactly 1 parameter, 2 given in %s on line %d
|
||||
|
||||
Warning: IntlCalendar::setRepeatedWallTimeOption(): intlcal_set_repeated_wall_time_option: bad arguments in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: IntlCalendar::setSkippedWallTimeOption() expects parameter 1 to be long, array given in %s on line %d
|
||||
|
||||
Warning: IntlCalendar::setSkippedWallTimeOption(): intlcal_set_skipped_wall_time_option: bad arguments in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: IntlCalendar::setRepeatedWallTimeOption() expects parameter 1 to be long, array given in %s on line %d
|
||||
|
||||
Warning: IntlCalendar::setRepeatedWallTimeOption(): intlcal_set_repeated_wall_time_option: bad arguments in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: IntlCalendar::setSkippedWallTimeOption(): intlcal_set_skipped_wall_time_option: invalid option in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: IntlCalendar::setRepeatedWallTimeOption(): intlcal_set_repeated_wall_time_option: invalid option in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: intlcal_set_skipped_wall_time_option() expects exactly 2 parameters, 1 given in %s on line %d
|
||||
|
||||
Warning: intlcal_set_skipped_wall_time_option(): intlcal_set_skipped_wall_time_option: bad arguments in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: intlcal_set_repeated_wall_time_option() expects exactly 2 parameters, 1 given in %s on line %d
|
||||
|
||||
Warning: intlcal_set_repeated_wall_time_option(): intlcal_set_repeated_wall_time_option: bad arguments in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Catchable fatal error: Argument 1 passed to intlcal_set_repeated_wall_time_option() must be an instance of IntlCalendar, integer given in %s on line %d
|
39
ext/intl/tests/calendar_setTimeZone_basic.phpt
Normal file
39
ext/intl/tests/calendar_setTimeZone_basic.phpt
Normal file
@ -0,0 +1,39 @@
|
||||
--TEST--
|
||||
IntlCalendar::setTimeZone() basic test
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded('intl'))
|
||||
die('skip intl extension not enabled');
|
||||
if (version_compare(INTL_ICU_VERSION, '4.8') < 0)
|
||||
die('skip for ICU 4.8+');
|
||||
--FILE--
|
||||
<?php
|
||||
ini_set("intl.error_level", E_WARNING);
|
||||
ini_set("intl.default_locale", "nl");
|
||||
|
||||
$intlcal = IntlCalendar::createInstance('Europe/Amsterdam');
|
||||
print_r($intlcal->getTimeZone()->getID());
|
||||
echo "\n";
|
||||
var_dump($intlcal->get(IntlCalendar::FIELD_ZONE_OFFSET));
|
||||
|
||||
$intlcal->setTimeZone(IntlTimeZone::getGMT());
|
||||
print_r($intlcal->getTimeZone()->getID());
|
||||
echo "\n";
|
||||
var_dump($intlcal->get(IntlCalendar::FIELD_ZONE_OFFSET));
|
||||
|
||||
intlcal_set_time_zone($intlcal,
|
||||
IntlTimeZone::createTimeZone('GMT+05:30'));
|
||||
print_r($intlcal->getTimeZone()->getID());
|
||||
echo "\n";
|
||||
var_dump($intlcal->get(IntlCalendar::FIELD_ZONE_OFFSET));
|
||||
|
||||
?>
|
||||
==DONE==
|
||||
--EXPECT--
|
||||
Europe/Amsterdam
|
||||
int(3600000)
|
||||
GMT
|
||||
int(0)
|
||||
GMT+05:30
|
||||
int(19800000)
|
||||
==DONE==
|
46
ext/intl/tests/calendar_setTimeZone_error.phpt
Normal file
46
ext/intl/tests/calendar_setTimeZone_error.phpt
Normal file
@ -0,0 +1,46 @@
|
||||
--TEST--
|
||||
IntlCalendar::setTimeZone(): bad arguments
|
||||
--INI--
|
||||
date.timezone=Atlantic/Azores
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded('intl'))
|
||||
die('skip intl extension not enabled');
|
||||
--FILE--
|
||||
<?php
|
||||
ini_set("intl.error_level", E_WARNING);
|
||||
|
||||
$c = new IntlGregorianCalendar(NULL, 'pt_PT');
|
||||
|
||||
$gmt = IntlTimeZone::getGMT();
|
||||
|
||||
function eh($errno, $errstr) {
|
||||
echo "error: $errno, $errstr\n";
|
||||
}
|
||||
set_error_handler('eh');
|
||||
|
||||
var_dump($c->setTimeZone($gmt, 2));
|
||||
var_dump($c->setTimeZone(1));
|
||||
var_dump($c->setTimeZone());
|
||||
|
||||
var_dump(intlcal_set_time_zone($c, 1));
|
||||
var_dump(intlcal_set_time_zone(1, $gmt));
|
||||
--EXPECT--
|
||||
error: 2, IntlCalendar::setTimeZone() expects exactly 1 parameter, 2 given
|
||||
error: 2, IntlCalendar::setTimeZone(): intlcal_set_time_zone: bad arguments
|
||||
bool(false)
|
||||
error: 4096, Argument 1 passed to IntlCalendar::setTimeZone() must be an instance of IntlTimeZone, integer given
|
||||
error: 2, IntlCalendar::setTimeZone() expects parameter 1 to be IntlTimeZone, integer given
|
||||
error: 2, IntlCalendar::setTimeZone(): intlcal_set_time_zone: bad arguments
|
||||
bool(false)
|
||||
error: 2, IntlCalendar::setTimeZone() expects exactly 1 parameter, 0 given
|
||||
error: 2, IntlCalendar::setTimeZone(): intlcal_set_time_zone: bad arguments
|
||||
bool(false)
|
||||
error: 4096, Argument 2 passed to intlcal_set_time_zone() must be an instance of IntlTimeZone, integer given
|
||||
error: 2, intlcal_set_time_zone() expects parameter 2 to be IntlTimeZone, integer given
|
||||
error: 2, intlcal_set_time_zone(): intlcal_set_time_zone: bad arguments
|
||||
bool(false)
|
||||
error: 4096, Argument 1 passed to intlcal_set_time_zone() must be an instance of IntlCalendar, integer given
|
||||
error: 2, intlcal_set_time_zone() expects parameter 1 to be IntlCalendar, integer given
|
||||
error: 2, intlcal_set_time_zone(): intlcal_set_time_zone: bad arguments
|
||||
bool(false)
|
30
ext/intl/tests/calendar_setTimeZone_variation1.phpt
Normal file
30
ext/intl/tests/calendar_setTimeZone_variation1.phpt
Normal file
@ -0,0 +1,30 @@
|
||||
--TEST--
|
||||
IntlCalendar::setTimeZone() variation with NULL arg
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded('intl'))
|
||||
die('skip intl extension not enabled');
|
||||
--FILE--
|
||||
<?php
|
||||
ini_set("intl.error_level", E_WARNING);
|
||||
ini_set("intl.default_locale", "nl");
|
||||
|
||||
$intlcal = IntlCalendar::createInstance('Europe/Amsterdam');
|
||||
print_r($intlcal->getTimeZone()->getID());
|
||||
echo "\n";
|
||||
var_dump($intlcal->get(IntlCalendar::FIELD_ZONE_OFFSET));
|
||||
|
||||
/* passing NULL has no effect */
|
||||
$intlcal->setTimeZone(null);
|
||||
print_r($intlcal->getTimeZone()->getID());
|
||||
echo "\n";
|
||||
var_dump($intlcal->get(IntlCalendar::FIELD_ZONE_OFFSET));
|
||||
|
||||
?>
|
||||
==DONE==
|
||||
--EXPECT--
|
||||
Europe/Amsterdam
|
||||
int(3600000)
|
||||
Europe/Amsterdam
|
||||
int(3600000)
|
||||
==DONE==
|
33
ext/intl/tests/calendar_setTime_basic.phpt
Normal file
33
ext/intl/tests/calendar_setTime_basic.phpt
Normal file
@ -0,0 +1,33 @@
|
||||
--TEST--
|
||||
IntlCalendar::setTime() basic test
|
||||
--INI--
|
||||
date.timezone=Atlantic/Azores
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded('intl'))
|
||||
die('skip intl extension not enabled');
|
||||
--FILE--
|
||||
<?php
|
||||
ini_set("intl.error_level", E_WARNING);
|
||||
ini_set("intl.default_locale", "nl");
|
||||
|
||||
$time = strtotime('2012-02-29 00:00:00 +0000');
|
||||
|
||||
$intlcal = IntlCalendar::createInstance('UTC');
|
||||
$intlcal->setTime($time * 1000);
|
||||
|
||||
var_dump(
|
||||
(float)$time*1000,
|
||||
$intlcal->getTime());
|
||||
|
||||
$intlcal = IntlCalendar::createInstance('UTC');
|
||||
intlcal_set_time($intlcal,$time * 1000);
|
||||
var_dump(intlcal_get_time($intlcal));
|
||||
|
||||
?>
|
||||
==DONE==
|
||||
--EXPECT--
|
||||
float(1330473600000)
|
||||
float(1330473600000)
|
||||
float(1330473600000)
|
||||
==DONE==
|
37
ext/intl/tests/calendar_setTime_error.phpt
Normal file
37
ext/intl/tests/calendar_setTime_error.phpt
Normal file
@ -0,0 +1,37 @@
|
||||
--TEST--
|
||||
IntlCalendar::setTime(): bad arguments
|
||||
--INI--
|
||||
date.timezone=Atlantic/Azores
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded('intl'))
|
||||
die('skip intl extension not enabled');
|
||||
--FILE--
|
||||
<?php
|
||||
ini_set("intl.error_level", E_WARNING);
|
||||
|
||||
$c = new IntlGregorianCalendar(NULL, 'pt_PT');
|
||||
|
||||
var_dump($c->setTime(1, 2));
|
||||
var_dump($c->setTime("jjj"));
|
||||
|
||||
var_dump(intlcal_set_time($c, 1, 2));
|
||||
var_dump(intlcal_set_time(1));
|
||||
--EXPECTF--
|
||||
|
||||
Warning: IntlCalendar::setTime() expects exactly 1 parameter, 2 given in %s on line %d
|
||||
|
||||
Warning: IntlCalendar::setTime(): intlcal_set_time: bad arguments in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: IntlCalendar::setTime() expects parameter 1 to be double, string given in %s on line %d
|
||||
|
||||
Warning: IntlCalendar::setTime(): intlcal_set_time: bad arguments in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: intlcal_set_time() expects exactly 2 parameters, 3 given in %s on line %d
|
||||
|
||||
Warning: intlcal_set_time(): intlcal_set_time: bad arguments in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Catchable fatal error: Argument 1 passed to intlcal_set_time() must be an instance of IntlCalendar, integer given in %s on line %d
|
27
ext/intl/tests/calendar_set_basic.phpt
Normal file
27
ext/intl/tests/calendar_set_basic.phpt
Normal file
@ -0,0 +1,27 @@
|
||||
--TEST--
|
||||
IntlCalendar::set() basic test
|
||||
--INI--
|
||||
date.timezone=Atlantic/Azores
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded('intl'))
|
||||
die('skip intl extension not enabled');
|
||||
--FILE--
|
||||
<?php
|
||||
ini_set("intl.error_level", E_WARNING);
|
||||
ini_set("intl.default_locale", "nl");
|
||||
|
||||
$intlcal = IntlCalendar::createInstance();
|
||||
var_dump($intlcal->set(IntlCalendar::FIELD_DAY_OF_MONTH, 2));
|
||||
var_dump($intlcal->get(IntlCalendar::FIELD_DAY_OF_MONTH));
|
||||
var_dump(intlcal_set($intlcal, IntlCalendar::FIELD_DAY_OF_MONTH, 3));
|
||||
var_dump($intlcal->get(IntlCalendar::FIELD_DAY_OF_MONTH));
|
||||
|
||||
?>
|
||||
==DONE==
|
||||
--EXPECT--
|
||||
bool(true)
|
||||
int(2)
|
||||
bool(true)
|
||||
int(3)
|
||||
==DONE==
|
41
ext/intl/tests/calendar_set_error.phpt
Normal file
41
ext/intl/tests/calendar_set_error.phpt
Normal file
@ -0,0 +1,41 @@
|
||||
--TEST--
|
||||
IntlCalendar::set(): bad arguments
|
||||
--INI--
|
||||
date.timezone=Atlantic/Azores
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded('intl'))
|
||||
die('skip intl extension not enabled');
|
||||
--FILE--
|
||||
<?php
|
||||
ini_set("intl.error_level", E_WARNING);
|
||||
|
||||
$c = new IntlGregorianCalendar(NULL, 'pt_PT');
|
||||
|
||||
var_dump($c->set(1));
|
||||
var_dump($c->set(1, 2, 3, 4));
|
||||
var_dump($c->set(1, 2, 3, 4, 5, 6, 7));
|
||||
var_dump($c->set(-1, 2));
|
||||
|
||||
var_dump(intlcal_set($c, -1, 2));
|
||||
var_dump(intlcal_set(1, 2, 3));
|
||||
--EXPECTF--
|
||||
|
||||
Warning: IntlCalendar::set() expects at least 2 parameters, 1 given in %s on line %d
|
||||
|
||||
Warning: IntlCalendar::set(): intlcal_set: bad arguments in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: IntlCalendar::set(): intlcal_set: bad arguments in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: IntlCalendar::set(): intlcal_set: too many arguments in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: IntlCalendar::set(): intlcal_set: invalid field in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: intlcal_set(): intlcal_set: invalid field in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Catchable fatal error: Argument 1 passed to intlcal_set() must be an instance of IntlCalendar, integer given in %s on line %d
|
41
ext/intl/tests/calendar_set_variation1.phpt
Normal file
41
ext/intl/tests/calendar_set_variation1.phpt
Normal file
@ -0,0 +1,41 @@
|
||||
--TEST--
|
||||
IntlCalendar::set() argument variations
|
||||
--INI--
|
||||
date.timezone=Atlantic/Azores
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded('intl'))
|
||||
die('skip intl extension not enabled');
|
||||
--FILE--
|
||||
<?php
|
||||
ini_set("intl.error_level", E_WARNING);
|
||||
ini_set("intl.default_locale", "nl");
|
||||
|
||||
$intlcal = IntlCalendar::createInstance('UTC');
|
||||
$intlcal->clear();
|
||||
var_dump($intlcal->set(2012, 1, 29));
|
||||
var_dump($intlcal->getTime(),
|
||||
strtotime('2012-02-29 00:00:00 +0000') * 1000.);
|
||||
|
||||
//two minutes to midnight!
|
||||
var_dump($intlcal->set(2012, 1, 29, 23, 58));
|
||||
var_dump($intlcal->getTime(),
|
||||
strtotime('2012-02-29 23:58:00 +0000') * 1000.);
|
||||
|
||||
var_dump($intlcal->set(2012, 1, 29, 23, 58, 31));
|
||||
var_dump($intlcal->getTime(),
|
||||
strtotime('2012-02-29 23:58:31 +0000') * 1000.);
|
||||
|
||||
?>
|
||||
==DONE==
|
||||
--EXPECT--
|
||||
bool(true)
|
||||
float(1330473600000)
|
||||
float(1330473600000)
|
||||
bool(true)
|
||||
float(1330559880000)
|
||||
float(1330559880000)
|
||||
bool(true)
|
||||
float(1330559911000)
|
||||
float(1330559911000)
|
||||
==DONE==
|
51
ext/intl/tests/gregoriancalendar___construct_basic.phpt
Normal file
51
ext/intl/tests/gregoriancalendar___construct_basic.phpt
Normal file
@ -0,0 +1,51 @@
|
||||
--TEST--
|
||||
IntlGregorianCalendar::__construct(): basic
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded('intl'))
|
||||
die('skip intl extension not enabled');
|
||||
if (version_compare(INTL_ICU_VERSION, '4.8') < 0)
|
||||
die('skip for ICU 4.8+');
|
||||
--FILE--
|
||||
<?php
|
||||
ini_set("intl.error_level", E_WARNING);
|
||||
ini_set("intl.default_locale", "nl");
|
||||
|
||||
date_default_timezone_set('Europe/Amsterdam');
|
||||
|
||||
$intlcal = intlgregcal_create_instance();
|
||||
var_dump($intlcal->getTimeZone()->getId());
|
||||
var_dump($intlcal->getLocale(1));
|
||||
|
||||
$intlcal = new IntlGregorianCalendar('Europe/Lisbon', NULL);
|
||||
var_dump($intlcal->getTimeZone()->getId());
|
||||
var_dump($intlcal->getLocale(1));
|
||||
|
||||
$intlcal = new IntlGregorianCalendar(NULL, 'pt_PT');
|
||||
var_dump($intlcal->getTimeZone()->getId());
|
||||
var_dump($intlcal->getLocale(1));
|
||||
|
||||
$intlcal = new IntlGregorianCalendar('Europe/Lisbon', 'pt_PT');
|
||||
var_dump($intlcal->getTimeZone()->getId());
|
||||
var_dump($intlcal->getLocale(1));
|
||||
|
||||
$intlcal = new IntlGregorianCalendar('Europe/Paris', 'fr_CA', NULL, NULL, NULL, NULL);
|
||||
var_dump($intlcal->getTimeZone()->getId());
|
||||
var_dump($intlcal->getLocale(1));
|
||||
|
||||
var_dump($intlcal->getType());
|
||||
?>
|
||||
==DONE==
|
||||
--EXPECT--
|
||||
string(16) "Europe/Amsterdam"
|
||||
string(5) "nl_NL"
|
||||
string(13) "Europe/Lisbon"
|
||||
string(5) "nl_NL"
|
||||
string(16) "Europe/Amsterdam"
|
||||
string(5) "pt_PT"
|
||||
string(13) "Europe/Lisbon"
|
||||
string(5) "pt_PT"
|
||||
string(12) "Europe/Paris"
|
||||
string(5) "fr_CA"
|
||||
string(9) "gregorian"
|
||||
==DONE==
|
35
ext/intl/tests/gregoriancalendar___construct_error.phpt
Normal file
35
ext/intl/tests/gregoriancalendar___construct_error.phpt
Normal file
@ -0,0 +1,35 @@
|
||||
--TEST--
|
||||
IntlGregorianCalendar::__construct(): bad arguments
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded('intl'))
|
||||
die('skip intl extension not enabled');
|
||||
--FILE--
|
||||
<?php
|
||||
ini_set("intl.error_level", E_WARNING);
|
||||
|
||||
var_dump(intlgregcal_create_instance(1,2,3,4,5,6,7));
|
||||
var_dump(intlgregcal_create_instance(1,2,3,4,5,6,7,8));
|
||||
var_dump(intlgregcal_create_instance(1,2,3,4));
|
||||
var_dump(new IntlGregorianCalendar(1,2,NULL,4));
|
||||
var_dump(new IntlGregorianCalendar(1,2,3,4,NULL,array()));
|
||||
|
||||
|
||||
--EXPECTF--
|
||||
|
||||
Warning: intlgregcal_create_instance(): intlgregcal_create_instance: too many arguments in %s on line %d
|
||||
NULL
|
||||
|
||||
Warning: intlgregcal_create_instance(): intlgregcal_create_instance: too many arguments in %s on line %d
|
||||
NULL
|
||||
|
||||
Warning: intlgregcal_create_instance(): intlgregcal_create_instance: no variant with 4 arguments (excluding trailing NULLs) in %s on line %d
|
||||
NULL
|
||||
|
||||
Warning: IntlGregorianCalendar::__construct(): intlgregcal_create_instance: no variant with 4 arguments (excluding trailing NULLs) in %s on line %d
|
||||
NULL
|
||||
|
||||
Warning: IntlGregorianCalendar::__construct() expects parameter 6 to be long, array given in %s on line %d
|
||||
|
||||
Warning: IntlGregorianCalendar::__construct(): intlgregcal_create_instance: bad arguments in %s on line %d
|
||||
NULL
|
30
ext/intl/tests/gregoriancalendar___construct_variant1.phpt
Normal file
30
ext/intl/tests/gregoriancalendar___construct_variant1.phpt
Normal file
@ -0,0 +1,30 @@
|
||||
--TEST--
|
||||
IntlGregorianCalendar::__construct(): argument variants
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded('intl'))
|
||||
die('skip intl extension not enabled');
|
||||
--FILE--
|
||||
<?php
|
||||
ini_set("intl.error_level", E_WARNING);
|
||||
|
||||
date_default_timezone_set('Europe/Amsterdam');
|
||||
|
||||
$intlcal = intlgregcal_create_instance(2012, 1, 29, 16, 0, NULL);
|
||||
var_dump($intlcal->getTimeZone()->getId());
|
||||
var_dump($intlcal->getTime(), (float)strtotime('2012-02-29 16:00:00') * 1000);
|
||||
|
||||
$intlcal = new IntlGregorianCalendar(2012, 1, 29, 16, 7, 8);
|
||||
var_dump($intlcal->getTime(), (float)strtotime('2012-02-29 16:07:08') * 1000);
|
||||
|
||||
var_dump($intlcal->getType());
|
||||
?>
|
||||
==DONE==
|
||||
--EXPECT--
|
||||
string(16) "Europe/Amsterdam"
|
||||
float(1330527600000)
|
||||
float(1330527600000)
|
||||
float(1330528028000)
|
||||
float(1330528028000)
|
||||
string(9) "gregorian"
|
||||
==DONE==
|
@ -0,0 +1,30 @@
|
||||
--TEST--
|
||||
IntlGregorianCalendar::getGregorianChange(): bad arguments
|
||||
--INI--
|
||||
date.timezone=Atlantic/Azores
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded('intl'))
|
||||
die('skip intl extension not enabled');
|
||||
--FILE--
|
||||
<?php
|
||||
ini_set("intl.error_level", E_WARNING);
|
||||
|
||||
$c = new IntlGregorianCalendar(NULL, 'pt_PT');
|
||||
var_dump($c->getGregorianChange(1));
|
||||
|
||||
var_dump(intlgregcal_get_gregorian_change($c, 1));
|
||||
var_dump(intlgregcal_get_gregorian_change(1));
|
||||
--EXPECTF--
|
||||
|
||||
Warning: IntlGregorianCalendar::getGregorianChange() expects exactly 0 parameters, 1 given in %s on line %d
|
||||
|
||||
Warning: IntlGregorianCalendar::getGregorianChange(): intlgregcal_get_gregorian_change: bad arguments in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: intlgregcal_get_gregorian_change() expects exactly 1 parameter, 2 given in %s on line %d
|
||||
|
||||
Warning: intlgregcal_get_gregorian_change(): intlgregcal_get_gregorian_change: bad arguments in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Catchable fatal error: Argument 1 passed to intlgregcal_get_gregorian_change() must be an instance of IntlGregorianCalendar, integer given in %s on line %d
|
@ -0,0 +1,32 @@
|
||||
--TEST--
|
||||
IntlGregorianCalendar::get/setGregorianChange(): basic test
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded('intl'))
|
||||
die('skip intl extension not enabled');
|
||||
--FILE--
|
||||
<?php
|
||||
ini_set("intl.error_level", E_WARNING);
|
||||
ini_set("intl.default_locale", "nl");
|
||||
|
||||
date_default_timezone_set('Europe/Amsterdam');
|
||||
|
||||
$intlcal = new IntlGregorianCalendar();
|
||||
|
||||
var_dump($intlcal->getGregorianChange());
|
||||
|
||||
var_dump($intlcal->setGregorianChange(0));
|
||||
var_dump(intlgregcal_get_gregorian_change($intlcal));
|
||||
|
||||
var_dump(intlgregcal_set_gregorian_change($intlcal, 1));
|
||||
var_dump($intlcal->getGregorianChange());
|
||||
|
||||
?>
|
||||
==DONE==
|
||||
--EXPECT--
|
||||
float(-12219292800000)
|
||||
bool(true)
|
||||
float(0)
|
||||
bool(true)
|
||||
float(1)
|
||||
==DONE==
|
28
ext/intl/tests/gregoriancalendar_isLeapYear_basic.phpt
Normal file
28
ext/intl/tests/gregoriancalendar_isLeapYear_basic.phpt
Normal file
@ -0,0 +1,28 @@
|
||||
--TEST--
|
||||
IntlGregorianCalendar::isLeapYear(): basic test
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded('intl'))
|
||||
die('skip intl extension not enabled');
|
||||
--FILE--
|
||||
<?php
|
||||
ini_set("intl.error_level", E_WARNING);
|
||||
ini_set("intl.default_locale", "nl");
|
||||
|
||||
date_default_timezone_set('Europe/Amsterdam');
|
||||
|
||||
$intlcal = new IntlGregorianCalendar();
|
||||
|
||||
var_dump($intlcal->isLeapYear(2012));
|
||||
var_dump($intlcal->isLeapYear(1900));
|
||||
|
||||
var_dump(intlgregcal_is_leap_year($intlcal, 2012));
|
||||
var_dump(intlgregcal_is_leap_year($intlcal, 1900));
|
||||
?>
|
||||
==DONE==
|
||||
--EXPECT--
|
||||
bool(true)
|
||||
bool(false)
|
||||
bool(true)
|
||||
bool(false)
|
||||
==DONE==
|
48
ext/intl/tests/gregoriancalendar_isLeapYear_error.phpt
Normal file
48
ext/intl/tests/gregoriancalendar_isLeapYear_error.phpt
Normal file
@ -0,0 +1,48 @@
|
||||
--TEST--
|
||||
IntlGregorianCalendar::isLeapYear(): bad arguments
|
||||
--INI--
|
||||
date.timezone=Atlantic/Azores
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded('intl'))
|
||||
die('skip intl extension not enabled');
|
||||
--FILE--
|
||||
<?php
|
||||
ini_set("intl.error_level", E_WARNING);
|
||||
|
||||
$c = new IntlGregorianCalendar(NULL, 'pt_PT');
|
||||
var_dump($c->isLeapYear(2000, 2011));
|
||||
var_dump($c->isLeapYear());
|
||||
var_dump($c->isLeapYear("fgdf"));
|
||||
|
||||
var_dump(intlgregcal_is_leap_year($c, 1, 2));
|
||||
var_dump(intlgregcal_is_leap_year($c));
|
||||
var_dump(intlgregcal_is_leap_year(1, 2));
|
||||
--EXPECTF--
|
||||
|
||||
Warning: IntlGregorianCalendar::isLeapYear() expects exactly 1 parameter, 2 given in %s on line %d
|
||||
|
||||
Warning: IntlGregorianCalendar::isLeapYear(): intlgregcal_is_leap_year: bad arguments in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: IntlGregorianCalendar::isLeapYear() expects exactly 1 parameter, 0 given in %s on line %d
|
||||
|
||||
Warning: IntlGregorianCalendar::isLeapYear(): intlgregcal_is_leap_year: bad arguments in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: IntlGregorianCalendar::isLeapYear() expects parameter 1 to be long, string given in %s on line %d
|
||||
|
||||
Warning: IntlGregorianCalendar::isLeapYear(): intlgregcal_is_leap_year: bad arguments in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: intlgregcal_is_leap_year() expects exactly 2 parameters, 3 given in %s on line %d
|
||||
|
||||
Warning: intlgregcal_is_leap_year(): intlgregcal_is_leap_year: bad arguments in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: intlgregcal_is_leap_year() expects exactly 2 parameters, 1 given in %s on line %d
|
||||
|
||||
Warning: intlgregcal_is_leap_year(): intlgregcal_is_leap_year: bad arguments in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Catchable fatal error: Argument 1 passed to intlgregcal_is_leap_year() must be an instance of IntlGregorianCalendar, integer given in %s on line %d
|
@ -0,0 +1,42 @@
|
||||
--TEST--
|
||||
IntlGregorianCalendar::setGregorianChange(): bad arguments
|
||||
--INI--
|
||||
date.timezone=Atlantic/Azores
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded('intl'))
|
||||
die('skip intl extension not enabled');
|
||||
--FILE--
|
||||
<?php
|
||||
ini_set("intl.error_level", E_WARNING);
|
||||
|
||||
$c = new IntlGregorianCalendar();
|
||||
var_dump($c->setGregorianChange());
|
||||
var_dump($c->setGregorianChange(1, 2));
|
||||
var_dump($c->setGregorianChange("sdfds"));
|
||||
|
||||
var_dump(intlgregcal_set_gregorian_change($c));
|
||||
var_dump(intlgregcal_set_gregorian_change(1, 4.));
|
||||
--EXPECTF--
|
||||
|
||||
Warning: IntlGregorianCalendar::setGregorianChange() expects exactly 1 parameter, 0 given in %s on line %d
|
||||
|
||||
Warning: IntlGregorianCalendar::setGregorianChange(): intlgregcal_set_gregorian_change: bad arguments in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: IntlGregorianCalendar::setGregorianChange() expects exactly 1 parameter, 2 given in %s on line %d
|
||||
|
||||
Warning: IntlGregorianCalendar::setGregorianChange(): intlgregcal_set_gregorian_change: bad arguments in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: IntlGregorianCalendar::setGregorianChange() expects parameter 1 to be double, string given in %s on line %d
|
||||
|
||||
Warning: IntlGregorianCalendar::setGregorianChange(): intlgregcal_set_gregorian_change: bad arguments in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: intlgregcal_set_gregorian_change() expects exactly 2 parameters, 1 given in %s on line %d
|
||||
|
||||
Warning: intlgregcal_set_gregorian_change(): intlgregcal_set_gregorian_change: bad arguments in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Catchable fatal error: Argument 1 passed to intlgregcal_set_gregorian_change() must be an instance of IntlGregorianCalendar, integer given in %s on line %d
|
@ -1,21 +1,21 @@
|
||||
--TEST--
|
||||
intl.use_exceptions INI setting
|
||||
--SKIPIF--
|
||||
<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
|
||||
--FILE--
|
||||
<?php
|
||||
ini_set("intl.use_exceptions", true);
|
||||
$t = transliterator_create('any-hex');
|
||||
try {
|
||||
var_dump($t->transliterate('a', 3));
|
||||
} catch (IntlException $intlE) {
|
||||
var_dump($intlE->getMessage());
|
||||
}
|
||||
ini_set("intl.use_exceptions", false);
|
||||
ini_set("intl.error_level", E_NOTICE);
|
||||
var_dump($t->transliterate('a', 3));
|
||||
--EXPECTF--
|
||||
string(130) "transliterator_transliterate: Neither "start" nor the "end" arguments can exceed the number of UTF-16 code units (in this case, 1)"
|
||||
|
||||
Notice: Transliterator::transliterate(): transliterator_transliterate: Neither "start" nor the "end" arguments can exceed the number of UTF-16 code units (in this case, 1) in %s on line %d
|
||||
bool(false)
|
||||
--TEST--
|
||||
intl.use_exceptions INI setting
|
||||
--SKIPIF--
|
||||
<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
|
||||
--FILE--
|
||||
<?php
|
||||
ini_set("intl.use_exceptions", true);
|
||||
$t = transliterator_create('any-hex');
|
||||
try {
|
||||
var_dump($t->transliterate('a', 3));
|
||||
} catch (IntlException $intlE) {
|
||||
var_dump($intlE->getMessage());
|
||||
}
|
||||
ini_set("intl.use_exceptions", false);
|
||||
ini_set("intl.error_level", E_NOTICE);
|
||||
var_dump($t->transliterate('a', 3));
|
||||
--EXPECTF--
|
||||
string(130) "transliterator_transliterate: Neither "start" nor the "end" arguments can exceed the number of UTF-16 code units (in this case, 1)"
|
||||
|
||||
Notice: Transliterator::transliterate(): transliterator_transliterate: Neither "start" nor the "end" arguments can exceed the number of UTF-16 code units (in this case, 1) in %s on line %d
|
||||
bool(false)
|
||||
|
51
ext/intl/tests/timezone_clone_basic.phpt
Normal file
51
ext/intl/tests/timezone_clone_basic.phpt
Normal file
@ -0,0 +1,51 @@
|
||||
--TEST--
|
||||
IntlTimeZone clone handler: basic test
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded('intl'))
|
||||
die('skip intl extension not enabled');
|
||||
--FILE--
|
||||
<?php
|
||||
ini_set("intl.error_level", E_WARNING);
|
||||
|
||||
$tz1 = IntlTimeZone::createTimeZone('Europe/Amsterdam');
|
||||
print_r($tz1);
|
||||
print_r(clone $tz1);
|
||||
|
||||
//clone non-owned object
|
||||
$gmt = IntlTimeZone::getGMT();
|
||||
print_r($gmt);
|
||||
print_r(clone $gmt);
|
||||
|
||||
?>
|
||||
==DONE==
|
||||
--EXPECTF--
|
||||
IntlTimeZone Object
|
||||
(
|
||||
[valid] => 1
|
||||
[id] => Europe/Amsterdam
|
||||
[rawOffset] => 3600000
|
||||
[currentOffset] => %d
|
||||
)
|
||||
IntlTimeZone Object
|
||||
(
|
||||
[valid] => 1
|
||||
[id] => Europe/Amsterdam
|
||||
[rawOffset] => 3600000
|
||||
[currentOffset] => %d
|
||||
)
|
||||
IntlTimeZone Object
|
||||
(
|
||||
[valid] => 1
|
||||
[id] => GMT
|
||||
[rawOffset] => 0
|
||||
[currentOffset] => 0
|
||||
)
|
||||
IntlTimeZone Object
|
||||
(
|
||||
[valid] => 1
|
||||
[id] => GMT
|
||||
[rawOffset] => 0
|
||||
[currentOffset] => 0
|
||||
)
|
||||
==DONE==
|
32
ext/intl/tests/timezone_clone_error.phpt
Normal file
32
ext/intl/tests/timezone_clone_error.phpt
Normal file
@ -0,0 +1,32 @@
|
||||
--TEST--
|
||||
IntlTimeZone clone handler: error test
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded('intl'))
|
||||
die('skip intl extension not enabled');
|
||||
--FILE--
|
||||
<?php
|
||||
ini_set("intl.error_level", E_WARNING);
|
||||
|
||||
class A extends IntlTimeZone {
|
||||
function __construct() {}
|
||||
}
|
||||
|
||||
$tz = new A();
|
||||
var_dump($tz);
|
||||
try {
|
||||
var_dump(clone $tz);
|
||||
} catch (Exception $e) {
|
||||
var_dump(get_class($e), $e->getMessage());
|
||||
}
|
||||
|
||||
?>
|
||||
==DONE==
|
||||
--EXPECT--
|
||||
object(A)#1 (1) {
|
||||
["valid"]=>
|
||||
bool(false)
|
||||
}
|
||||
string(9) "Exception"
|
||||
string(39) "Cannot clone unconstructed IntlTimeZone"
|
||||
==DONE==
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user