2 +----------------------------------------------------------------------+
4 +----------------------------------------------------------------------+
5 | Copyright (c) 2010-present Facebook, Inc. (http://www.facebook.com) |
6 | Copyright (c) 1997-2010 The PHP Group |
7 +----------------------------------------------------------------------+
8 | This source file is subject to version 3.01 of the PHP license, |
9 | that is bundled with this package in the file LICENSE, and is |
10 | available through the world-wide-web at the following url: |
11 | http://www.php.net/license/3_01.txt |
12 | If you did not receive a copy of the PHP license and are unable to |
13 | obtain it through the world-wide-web, please send a note to |
14 | license@php.net so we can mail you a copy immediately. |
15 +----------------------------------------------------------------------+
17 #ifndef incl_HPHP_ICU_DATE_FMT_H
18 #define incl_HPHP_ICU_DATE_FMT_H
20 #include "hphp/runtime/ext/extension.h"
21 #include "hphp/runtime/ext/icu/icu.h"
23 #include <unicode/udat.h>
24 #include <unicode/datefmt.h>
26 namespace HPHP
{ namespace Intl
{
27 /////////////////////////////////////////////////////////////////////////////
28 extern const StaticString s_IntlDateFormatter
;
30 struct IntlDateFormatter
: IntlError
{
31 IntlDateFormatter() {}
32 IntlDateFormatter(const IntlDateFormatter
&) = delete;
33 IntlDateFormatter
& operator=(const IntlDateFormatter
& src
) {
34 setDateFormatter(&src
);
37 ~IntlDateFormatter() {
39 udat_close((UDateFormat
*)m_date_fmt
);
44 void setDateFormatter(const String
& locale
,
45 int64_t datetype
, int64_t timetype
,
46 const Variant
& timezone
, const Variant
& calendar
,
47 const String
& pattern
);
48 void setDateFormatter(const IntlDateFormatter
*orig
);
50 bool isValid() const {
54 static Object
newInstance() {
55 if (!c_IntlDateFormatter
) {
56 c_IntlDateFormatter
= Unit::lookupClass(s_IntlDateFormatter
.get());
57 assertx(c_IntlDateFormatter
);
59 return Object
{c_IntlDateFormatter
};
61 static IntlDateFormatter
* Get(ObjectData
* obj
) {
62 return GetData
<IntlDateFormatter
>(obj
, s_IntlDateFormatter
);
65 // Zend seems to think casting UDateFormat* to icu::DateFormat*
66 // is a good idea. Sounds dodgy as heck to me though...
67 icu::DateFormat
*datefmtObject() const {return (icu::DateFormat
*)m_date_fmt
;}
68 UDateFormat
*datefmt() const { return m_date_fmt
; }
69 int64_t dateType() const { return m_date_type
; }
70 int64_t timeType() const { return m_time_type
; }
71 int64_t calendar() const { return m_calendar
; }
73 int64_t getArrayElemInt(const Array
& arr
, const StaticString
&key
);
74 double getTimestamp(const Variant
& arg
);
77 UDateFormat
*m_date_fmt
= nullptr;
83 static Class
* c_IntlDateFormatter
;
86 /////////////////////////////////////////////////////////////////////////////
87 }} // namespace HPHP::Intl
88 #endif // incl_HPHP_ICU_DATE_FMT_H