rok commented on a change in pull request #10647:
URL: https://github.com/apache/arrow/pull/10647#discussion_r670801579
##########
File path: cpp/src/arrow/compute/kernels/scalar_temporal_test.cc
##########
@@ -216,5 +216,40 @@ TEST_F(ScalarTemporalTest, DayOfWeek) {
DayOfWeek(timestamps,
DayOfWeekOptions(/*one_based_numbering=*/false,
/*week_start=*/8)));
}
+
+#ifndef _WIN32
+TEST_F(ScalarTemporalTest, Strftime) {
+ auto options_seconds = StrftimeOptions("%Y-%m-%dT%H:%M:%S%z", "UTC");
+ auto options_milliseconds = StrftimeOptions("%Y-%m-%dT%H:%M:%S%z", "GMT");
+ auto options_microseconds = StrftimeOptions("%Y-%m-%dT%H:%M:%S%z",
"Asia/Kolkata");
+ auto options_nanoseconds = StrftimeOptions("%Y-%m-%dT%H:%M:%S%z",
"US/Hawaii");
+
+ const char* times_seconds = R"(["1970-01-01T00:00:59", null])";
+ const char* times_milliseconds = R"(["1970-01-01T00:00:59.123", null])";
+ const char* times_microseconds = R"(["1970-01-01T00:00:59.123456", null])";
+ const char* times_nanoseconds = R"(["1970-01-01T00:00:59.123456789", null])";
+
+ const char* zoned_seconds = R"(["1970-01-01T00:00:59+0000", null])";
+ const char* zoned_milliseconds = R"(["1970-01-01T00:00:59.123+0000", null])";
Review comment:
`date.h` doesn't appear to have a `%f` flag.
[date.h](https://howardhinnant.github.io/date/date.html) doc states:
> ***%S*** | Seconds as a decimal number. If the number of seconds is less
than 10, the result is prefixed with 0. If the precision of the input can not
be exactly represented with seconds, then the format is a decimal floating
point number with a fixed format and a precision matching that of the precision
of the input (or to a microseconds precision if the conversion to floating
point decimal seconds can not be made within 18 fractional digits). The
character for the decimal point is localized according to the locale. The
modified command %OS produces the locale's alternative representation.
Which almost exactly matches [c++
formatter](https://en.cppreference.com/w/cpp/chrono/duration/formatter).
Implementing [python-like](https://strftime.org/) `%f` and `%S` would
require additional logic here.
R appears to have a [similar
convention](https://stat.ethz.ch/R-manual/R-devel/library/base/html/strptime.html)
to Python.
[SQLite](https://sqlite.org/lang_datefunc.html):
```
%f | | fractional seconds: SS.SSS
%S | | seconds: 00-59
```
[Postgres](https://www.postgresql.org/docs/9.1/ecpg-pgtypes.html):
```
%S - is replaced by the second as a decimal number (00-60).
No fractions.
```
[Ruby](https://apidock.com/ruby/DateTime/strftime):
```
%S - Second of the minute (00..59)
No fractions.
```
I kind of like the current behavior but it could would of course not cover
all cases.
--
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]