jorisvandenbossche commented on a change in pull request #7604:
URL: https://github.com/apache/arrow/pull/7604#discussion_r449479330



##########
File path: cpp/src/arrow/python/datetime.cc
##########
@@ -262,6 +302,42 @@ int64_t PyDate_to_days(PyDateTime_Date* pydate) {
                             PyDateTime_GET_DAY(pydate));
 }
 
+// GIL must be held when calling this function.
+Status StringToTzinfo(const std::string& tz, PyObject** tzinfo) {

Review comment:
       It might go a bit too far (and can easily get outdated), but given that 
the below is basically python code written in C++, for me it would help in 
understanding it by including the short python snippet that it represents as a 
comment, eg
   
   ```
   def string_to_tzinfo(tz):
       import pytz
   
       match = ... 
       if match:
           sign, hours, minutes = ...
           return pytz.FixedOffset(sign * (hours * 60 + minutes))
       else:
           return pytz.timezone(tz)
   ```

##########
File path: cpp/src/arrow/python/datetime.cc
##########
@@ -14,22 +14,62 @@
 // KIND, either express or implied.  See the License for the
 // specific language governing permissions and limitations
 // under the License.
+#include "arrow/python/datetime.h"
 
 #include <algorithm>
 #include <chrono>
 #include <iostream>
 
 #include "arrow/python/common.h"
-#include "arrow/python/datetime.h"
+#include "arrow/python/helpers.h"
 #include "arrow/python/platform.h"
 #include "arrow/status.h"
 #include "arrow/type.h"
 #include "arrow/util/logging.h"
+#include "arrow/util/value_parsing.h"
 
 namespace arrow {
 namespace py {
 namespace internal {
 
+namespace {
+
+bool MatchFixedOffset(const std::string& tz, util::string_view* sign,
+                      util::string_view* hour, util::string_view* minute) {
+  if (tz.size() < 5) {

Review comment:
       Maybe add a comment here that this can be replaced with a simpler regex 
once we can use std::regex? (and eg pointing to this PR to see the regex)




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to