Implement Intl's DateFormatter class
[hiphop-php.git] / hphp / runtime / ext / icu / ext_icu_timezone.h
blob70189a6fd27e5a70fcbbe700495871e16246802a
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 {
13 public:
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) {
23 delete m_timezone;
25 m_timezone = nullptr;
28 bool isInvalid() const override {
29 return m_timezone == nullptr;
32 static IntlTimeZone *Get(Object obj);
33 Object wrap();
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) ||
45 #endif
46 false;
49 icu::TimeZone* timezone() const { return m_timezone; }
51 static icu::TimeZone* ParseArg(CVarRef arg, const String& funcname,
52 intl_error &err);
53 private:
54 icu::TimeZone *m_timezone;
55 bool m_owned;
58 /////////////////////////////////////////////////////////////////////////////
59 }} // namespace HPHP::Intl
61 #endif // incl_HPHP_ICU_TIMEZONE_H