summaryrefslogtreecommitdiff
path: root/ext/intl/msgformat/msgformat_helpers.cpp
diff options
context:
space:
mode:
authorGustavo André dos Santos Lopes <cataphract@php.net>2012-05-17 17:45:15 +0200
committerGustavo André dos Santos Lopes <cataphract@php.net>2012-05-17 17:57:37 +0200
commitec23c3e5401f2bf4b752e8ae64383932135eef10 (patch)
treed994ca7e320ee1bed8e95ddbce972bfc51b8e207 /ext/intl/msgformat/msgformat_helpers.cpp
parentd754e9683aceb125dff62ea11fd0d6b1cdf7ca4e (diff)
downloadphp-git-ec23c3e5401f2bf4b752e8ae64383932135eef10.tar.gz
MessageFormatter accepts IntlCalendar arguments
Now MessageFormatter::format() accepts IntlCalendar objects to be used in arguments of type Format::kDate.
Diffstat (limited to 'ext/intl/msgformat/msgformat_helpers.cpp')
-rwxr-xr-xext/intl/msgformat/msgformat_helpers.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/ext/intl/msgformat/msgformat_helpers.cpp b/ext/intl/msgformat/msgformat_helpers.cpp
index 84c6f40c18..6f4615e169 100755
--- a/ext/intl/msgformat/msgformat_helpers.cpp
+++ b/ext/intl/msgformat/msgformat_helpers.cpp
@@ -28,6 +28,7 @@
#include <unicode/ustdio.h>
#include <unicode/timezone.h>
#include <unicode/datefmt.h>
+#include <unicode/calendar.h>
#include <vector>
@@ -39,6 +40,8 @@ extern "C" {
#include "msgformat_format.h"
#include "msgformat_helpers.h"
#include "intl_convert.h"
+#define USE_CALENDAR_POINTER 1
+#include "../calendar/calendar_class.h"
/* avoid redefinition of int8_t, already defined in unicode/pwin32.h */
#define _MSC_STDINT_H_ 1
#include "ext/date/php_date.h"
@@ -134,6 +137,14 @@ static double umsg_helper_zval_to_millis(zval *z, UErrorCode *status TSRMLS_DC)
rv = U_MILLIS_PER_SECOND * (double)Z_LVAL(retval);
}
zval_ptr_dtor(&zfuncname);
+ } else if (instanceof_function(Z_OBJCE_P(z), Calendar_ce_ptr TSRMLS_CC)) {
+ Calendar_object *co = (Calendar_object *)
+ zend_object_store_get_object(z TSRMLS_CC );
+ if (co->ucal == NULL) {
+ *status = U_ILLEGAL_ARGUMENT_ERROR;
+ } else {
+ rv = (double)co->ucal->getTime(*status);
+ }
} else {
/* TODO: try with cast(), get() to obtain a number */
*status = U_ILLEGAL_ARGUMENT_ERROR;