This is an automated email from the ASF dual-hosted git repository.

kou pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow.git


The following commit(s) were added to refs/heads/main by this push:
     new 3f25672916 GH-43808: [C++] skip `-0117` in StrptimeZoneOffset for old 
glibc (#44621)
3f25672916 is described below

commit 3f25672916ac97867c82be7d5d2fe87909c99752
Author: h-vetinari <[email protected]>
AuthorDate: Fri Nov 15 19:38:40 2024 +1100

    GH-43808: [C++] skip `-0117` in StrptimeZoneOffset for old glibc (#44621)
    
    
    
    ### Rationale for this change
    
    Enable tests for libarrow in conda-forge: 
https://github.com/apache/arrow/issues/35587
    
    ### What changes are included in this PR?
    
    old glibc does not actually support timezones like `-0117` (used in 
`StrptimeZoneOffset` test). The exact lower bound for glibc is hard for me to 
determine; I know that it passes with 2.28 and that it fails with 2.17. 
Anything in between is an open question. I went with the conservative option 
here.
    
    ### Are these changes tested?
    
    Tested in https://github.com/conda-forge/arrow-cpp-feedstock/pull/1058
    
    ### Are there any user-facing changes?
    
    * GitHub Issue: #43808
    
    Lead-authored-by: H. Vetinari <[email protected]>
    Co-authored-by: Sutou Kouhei <[email protected]>
    Signed-off-by: Sutou Kouhei <[email protected]>
---
 cpp/src/arrow/util/value_parsing_test.cc | 19 ++++++++++++++++---
 1 file changed, 16 insertions(+), 3 deletions(-)

diff --git a/cpp/src/arrow/util/value_parsing_test.cc 
b/cpp/src/arrow/util/value_parsing_test.cc
index 7cd1ab1e25..a833d266a8 100644
--- a/cpp/src/arrow/util/value_parsing_test.cc
+++ b/cpp/src/arrow/util/value_parsing_test.cc
@@ -838,12 +838,25 @@ TEST(TimestampParser, StrptimeZoneOffset) {
   std::string format = "%Y-%d-%m %H:%M:%S%z";
   auto parser = TimestampParser::MakeStrptime(format);
 
+  std::vector<std::string> values = {
+    "2018-01-01 00:00:00+0000",
+    "2018-01-01 00:00:00+0100",
+#if defined(__GLIBC__) && defined(__GLIBC_MINOR__)
+// glibc < 2.28 doesn't support "-0117" timezone offset.
+// See also: https://github.com/apache/arrow/issues/43808
+#  if ((__GLIBC__ == 2) && (__GLIBC_MINOR__ >= 28)) || (__GLIBC__ >= 3)
+    "2018-01-01 00:00:00-0117",
+#  endif
+#else
+    "2018-01-01 00:00:00-0117",
+#endif
+    "2018-01-01 00:00:00+0130"
+  };
+
   // N.B. GNU %z supports ISO8601 format while BSD %z supports only
   // +HHMM or -HHMM and POSIX doesn't appear to define %z at all
   for (auto unit : TimeUnit::values()) {
-    for (const std::string value :
-         {"2018-01-01 00:00:00+0000", "2018-01-01 00:00:00+0100",
-          "2018-01-01 00:00:00+0130", "2018-01-01 00:00:00-0117"}) {
+    for (const std::string& value : values) {
       SCOPED_TRACE(value);
       int64_t converted = 0;
       int64_t expected = 0;

Reply via email to