1 #ifndef incl_HPHP_ICU_TIMEZONE_H
2 #define incl_HPHP_ICU_TIMEZONE_H
4 #include "hphp/runtime/base/base-includes.h"
5 #include "hphp/runtime/ext/icu/icu.h"
7 #include <unicode/timezone.h>
9 namespace HPHP
{ namespace Intl
{
10 /////////////////////////////////////////////////////////////////////////////
12 class IntlTimeZone
: public IntlResourceData
{
14 DECLARE_RESOURCE_ALLOCATION_NO_SWEEP(IntlTimeZone
);
15 CLASSNAME_IS("IntlTimeZone");
16 const String
& o_getClassNameHook() const override
{ return classnameof(); }
18 explicit IntlTimeZone(icu::TimeZone
*tz
, bool owned
= true):
19 m_timezone(tz
), m_owned(owned
) {}
21 void sweep() override
{
22 if (m_timezone
&& m_owned
) {
28 bool isInvalid() const override
{
29 return m_timezone
== nullptr;
32 static IntlTimeZone
*Get(Object obj
);
35 static bool isValidStyle(int64_t style
) {
36 return (style
== icu::TimeZone::SHORT
) ||
37 (style
== icu::TimeZone::LONG
) ||
38 #if U_ICU_VERSION_MAJOR_NUM * 10 + U_ICU_VERSION_MINOR_NUM >= 44
39 (style
== icu::TimeZone::SHORT_GENERIC
) ||
40 (style
== icu::TimeZone::LONG_GENERIC
) ||
41 (style
== icu::TimeZone::SHORT_GMT
) ||
42 (style
== icu::TimeZone::LONG_GMT
) ||
43 (style
== icu::TimeZone::SHORT_COMMONLY_USED
) ||
44 (style
== icu::TimeZone::GENERIC_LOCATION
) ||
49 icu::TimeZone
* timezone() const { return m_timezone
; }
51 static icu::TimeZone
* ParseArg(CVarRef arg
, const String
& funcname
,
54 icu::TimeZone
*m_timezone
;
58 /////////////////////////////////////////////////////////////////////////////
59 }} // namespace HPHP::Intl
61 #endif // incl_HPHP_ICU_TIMEZONE_H