Commit 19ed8b12 authored by Andi Vajda's avatar Andi Vajda
Browse files

added wrapper for TimeZone.getRegion()

parent 582c3f0b
......@@ -2,6 +2,7 @@ Version 2.9 ->
- fixed bug with building on MacOS when pkg-config is present
- added link to note about building everything from sources
- added wrapper for u_cleanup/u_init sequence as ResourceBundle.resetICU()
- added wrapper for TimeZone.getRegion()
-
Version 2.8.1 -> 2.9
......
......@@ -35,6 +35,12 @@ class TestTimeZone(TestCase):
self.assertTrue(isinstance(tz, BasicTimeZone))
self.assertEqual(str(tz), "America/Los_Angeles")
def testGetRegion(self):
if ICU_VERSION >= '4.8':
self.assertEqual('US', TimeZone.getRegion("America/Los_Angeles"))
self.assertEqual('001', TimeZone.getRegion("CET"))
def testGetRules(self):
tz = TimeZone.createTimeZone("America/Los_Angeles")
......
......@@ -206,6 +206,9 @@ static PyObject *t_timezone_createEnumeration(PyTypeObject *type,
static PyObject *t_timezone_countEquivalentIDs(PyTypeObject *type,
PyObject *arg);
static PyObject *t_timezone_getEquivalentID(PyTypeObject *type, PyObject *args);
#if U_ICU_VERSION_HEX >= 0x04080000
static PyObject *t_timezone_getRegion(PyTypeObject *type, PyObject *arg);
#endif
#if U_ICU_VERSION_HEX >= VERSION_HEX(52, 0, 0)
static PyObject *t_timezone_getIDForWindowsID(PyTypeObject *type,
PyObject *args);
......@@ -230,6 +233,9 @@ static PyMethodDef t_timezone_methods[] = {
DECLARE_METHOD(t_timezone, createEnumeration, METH_VARARGS | METH_CLASS),
DECLARE_METHOD(t_timezone, countEquivalentIDs, METH_O | METH_CLASS),
DECLARE_METHOD(t_timezone, getEquivalentID, METH_VARARGS | METH_CLASS),
#if U_ICU_VERSION_HEX >= 0x04080000
DECLARE_METHOD(t_timezone, getRegion, METH_O | METH_CLASS),
#endif
#if U_ICU_VERSION_HEX >= VERSION_HEX(52, 0, 0)
DECLARE_METHOD(t_timezone, getIDForWindowsID, METH_VARARGS | METH_CLASS),
DECLARE_METHOD(t_timezone, getWindowsID, METH_O | METH_CLASS),
......@@ -1103,6 +1109,26 @@ static PyObject *t_timezone_getEquivalentID(PyTypeObject *type, PyObject *args)
return PyErr_SetArgsError(type, "getEquivalentID", args);
}
#if U_ICU_VERSION_HEX >= 0x04080000
static PyObject *t_timezone_getRegion(PyTypeObject *type, PyObject *arg)
{
UnicodeString *u;
UnicodeString _u;
if (!parseArg(arg, "S", &u, &_u))
{
char region[16];
int size;
STATUS_CALL(size = TimeZone::getRegion(*u, region, sizeof(region), status));
return PyString_FromStringAndSize(region, size);
}
return PyErr_SetArgsError(type, "getRegion", arg);
}
#endif
#if U_ICU_VERSION_HEX >= VERSION_HEX(52, 0, 0)
static PyObject *t_timezone_getIDForWindowsID(PyTypeObject *type,
PyObject *args)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment