AlenkaF commented on a change in pull request #12421:
URL: https://github.com/apache/arrow/pull/12421#discussion_r805931655
##########
File path: cpp/src/arrow/python/datetime.cc
##########
@@ -470,6 +474,26 @@ Result<std::string> TzinfoToString(PyObject* tzinfo) {
return result;
}
+ // try to look up key attribute
+ if (PyObject_HasAttrString(tzinfo, "key")) {
+ OwnedRef key(PyObject_GetAttrString(tzinfo, "key"));
+ RETURN_IF_PYERROR();
+ std::string result;
+ RETURN_NOT_OK(internal::PyUnicode_AsStdString(key.obj(), &result));
+ return result;
+ }
+
+ // try to look up _filename attribute
+ if (PyObject_HasAttrString(tzinfo, "_filename")) {
+ OwnedRef _filename(PyObject_GetAttrString(tzinfo, "_filename"));
+ RETURN_IF_PYERROR();
+ std::string result;
+ RETURN_NOT_OK(internal::PyUnicode_AsStdString(_filename.obj(), &result));
+ std::size_t pos = result.find("zoneinfo/");
+ if (pos > 0) {return result.substr (pos+9);}
Review comment:
I am not sure this is a way to do things in C++ part of Arrow. So I will
add a note to clarify. `Dateutil` package currently does not have a method to
extract POSIX name of the timezone. It is possible to use `_filename` but the
output can be `'/usr/share/zoneinfo/Europe/Brussels'` or `'Europe/Brussels'` as
in example:
```
>>> import dateutil.tz
>>> tz = dateutil.tz.gettz('Europe/Brussels')
>>> tz
tzfile('/usr/share/zoneinfo/Europe/Brussels')
>>> tz._filename
'/usr/share/zoneinfo/Europe/Brussels'
```
see https://github.com/dateutil/dateutil/issues/76#issuecomment-91226288.
For this reason I am selecting a substring to get the name from the
`tz._filename.` Please let me know if this is not a good way to go.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]