rok commented on a change in pull request #10647:
URL: https://github.com/apache/arrow/pull/10647#discussion_r690452017



##########
File path: cpp/src/arrow/compute/kernels/scalar_temporal_test.cc
##########
@@ -382,5 +382,75 @@ TEST_F(ScalarTemporalTest, DayOfWeek) {
                 DayOfWeek(timestamps, 
DayOfWeekOptions(/*one_based_numbering=*/false,
                                                        /*week_start=*/8)));
 }
+
+#ifndef _WIN32
+TEST_F(ScalarTemporalTest, Strftime) {
+  auto options_default = StrftimeOptions();
+  auto options = StrftimeOptions("%Y-%m-%dT%H:%M:%S%z");
+
+  const char* seconds = R"(["1970-01-01T00:00:59", null])";
+  const char* milliseconds = R"(["1970-01-01T00:00:59.123", null])";
+  const char* microseconds = R"(["1970-01-01T00:00:59.123456", null])";
+  const char* nanoseconds = R"(["1970-01-01T00:00:59.123456789", null])";
+
+  const char* default_seconds = R"(["1970-01-01T00:00:59Z", null])";
+  const char* string_seconds = R"(["1970-01-01T00:00:59+0000", null])";
+  const char* string_milliseconds = R"(["1970-01-01T00:00:59.123+0000", 
null])";
+  const char* string_microseconds = R"(["1970-01-01T05:30:59.123456+0530", 
null])";
+  const char* string_nanoseconds = R"(["1969-12-31T14:00:59.123456789-1000", 
null])";
+
+  CheckScalarUnary("strftime", timestamp(TimeUnit::SECOND, "UTC"), seconds, 
utf8(),
+                   default_seconds, &options_default);
+  CheckScalarUnary("strftime", timestamp(TimeUnit::SECOND, "UTC"), seconds, 
utf8(),
+                   string_seconds, &options);
+  CheckScalarUnary("strftime", timestamp(TimeUnit::MILLI, "GMT"), 
milliseconds, utf8(),
+                   string_milliseconds, &options);
+  CheckScalarUnary("strftime", timestamp(TimeUnit::MICRO, "Asia/Kolkata"), 
microseconds,
+                   utf8(), string_microseconds, &options);
+  CheckScalarUnary("strftime", timestamp(TimeUnit::NANO, "US/Hawaii"), 
nanoseconds,
+                   utf8(), string_nanoseconds, &options);
+
+  auto naive_times = ArrayFromJSON(timestamp(TimeUnit::SECOND), seconds);
+  ASSERT_RAISES(Invalid, Strftime(naive_times, options_default));
+  ASSERT_RAISES(Invalid, Strftime(naive_times, options));
+}
+
+TEST_F(ScalarTemporalTest, StrftimeWithLocale) {
+  auto options_default = StrftimeOptions();
+  auto options = StrftimeOptions("%Y-%m-%dT%H:%M:%S%z", "C");
+  auto options_locale_specific = StrftimeOptions("%a", "C");

Review comment:
       Please note this is only testing for `C` locale because that is all that 
is available in CI at the moment. Ideally we would cover several.




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


Reply via email to