You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "pearu (via GitHub)" <gi...@apache.org> on 2026/10/19 18:25:07 UTC
[PR] GH-54641: [C++] Support locale directives in the vendored strptime on Windows [arrow]
pearu opened a new pull request, #54656:
URL: https://github.com/apache/arrow/pull/54656
### Rationale for this change
On Windows, the vendored musl `strptime` does not handle `%a`, `%A`, `%b`, `%B`, `%h`, `%c`, `%p`, `%r`, `%x` and `%X`, because they need `nl_langinfo()`, which is not available there.
### What changes are included in this PR?
A C-locale replacement for `nl_langinfo()`, restricted to the items the vendored `strptime` uses. Defining `ARROW_TEST_FALLBACK_LANGINFO` compiles the replacement on other platforms as well, for manual testing.
### Are these changes tested?
Yes, `TimestampParser.StrptimeLocaleDirectives` covers each of these directives. On Windows it exercises the vendored `strptime`; elsewhere it runs against the system `strptime`.
### Are there any user-facing changes?
On Windows, `strptime` formats with these directives now parse.
### AI usage disclosure
Developed with AI assistance (Claude Code): the fix, the test and this description were AI-generated under my direction and reviewed line by line by me. I own and can debug these changes. No copyrighted material is included.
* GitHub Issue: #54641
--
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: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GH-54641: [C++] Support locale directives in the vendored strptime on Windows [arrow]
Posted by "pearu (via GitHub)" <gi...@apache.org>.
pearu commented on PR #54656:
URL: https://github.com/apache/arrow/pull/54656#issuecomment-6285777535
`strptime` is already vendored from musl and used on Windows; this PR only provides the `nl_langinfo()` data it needs there, so the directives that depend on it work.
--
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: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GH-54641: [C++] Support locale directives in the vendored strptime on Windows [arrow]
Posted by "pearu (via GitHub)" <gi...@apache.org>.
pearu commented on code in PR #54656:
URL: https://github.com/apache/arrow/pull/54656#discussion_r4322495539
##########
cpp/src/arrow/vendored/musl/strptime.c:
##########
@@ -17,12 +17,29 @@
#undef HAVE_LANGINFO
-#ifndef _WIN32
+#if !defined(_WIN32) && !defined(ARROW_TEST_FALLBACK_LANGINFO)
Review Comment:
It was only for compiling the fallback on Linux for manual testing. Removed; the fallback is tested by `StrptimeLocaleDirectives` on the Windows CI jobs.
##########
cpp/src/arrow/vendored/musl/strptime.c:
##########
@@ -17,12 +17,29 @@
#undef HAVE_LANGINFO
-#ifndef _WIN32
+#if !defined(_WIN32) && !defined(ARROW_TEST_FALLBACK_LANGINFO)
#define HAVE_LANGINFO 1
#endif
#ifdef HAVE_LANGINFO
#include <langinfo.h>
+#else
+// C-locale replacement for nl_langinfo(), restricted to the items used below.
+// The constants follow the glibc/musl layout that the symbolic_range loop
+// relies on: full names directly follow the abbreviated ones.
+enum { ABDAY_1 = 0, DAY_1 = 7, ABMON_1 = 14, MON_1 = 26, AM_STR = 38, PM_STR = 39,
+ D_T_FMT = 40, D_FMT = 41, T_FMT = 42, T_FMT_AMPM = 43 };
+static const char *arrow_c_langinfo[] = {
+ "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat",
+ "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday",
+ "Jan", "Feb", "Mar", "Apr", "May", "Jun",
+ "Jul", "Aug", "Sep", "Oct", "Nov", "Dec",
+ "January", "February", "March", "April", "May", "June",
+ "July", "August", "September", "October", "November", "December",
+ "AM", "PM",
+ "%a %b %e %T %Y", "%m/%d/%y", "%H:%M:%S", "%I:%M:%S %p"};
Review Comment:
They are the values of the [POSIX locale](https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/V1_chap07.html#tag_07_03_05_03) (`LC_TIME` in POSIX.1, chapter 7), which musl's own C locale ([`c_time` in `src/locale/langinfo.c`](https://git.musl-libc.org/cgit/musl/tree/src/locale/langinfo.c)) uses in the same order; [glibc's C locale](https://sourceware.org/git/?p=glibc.git;a=blob;f=locale/C-time.c) has the same values. Added this to the comment.
--
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: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GH-54641: [C++] Support locale directives in the vendored strptime on Windows [arrow]
Posted by "kou (via GitHub)" <gi...@apache.org>.
kou commented on code in PR #54656:
URL: https://github.com/apache/arrow/pull/54656#discussion_r4320966515
##########
cpp/src/arrow/vendored/musl/strptime.c:
##########
@@ -17,12 +17,29 @@
#undef HAVE_LANGINFO
-#ifndef _WIN32
+#if !defined(_WIN32) && !defined(ARROW_TEST_FALLBACK_LANGINFO)
#define HAVE_LANGINFO 1
#endif
#ifdef HAVE_LANGINFO
#include <langinfo.h>
+#else
+// C-locale replacement for nl_langinfo(), restricted to the items used below.
+// The constants follow the glibc/musl layout that the symbolic_range loop
+// relies on: full names directly follow the abbreviated ones.
+enum { ABDAY_1 = 0, DAY_1 = 7, ABMON_1 = 14, MON_1 = 26, AM_STR = 38, PM_STR = 39,
+ D_T_FMT = 40, D_FMT = 41, T_FMT = 42, T_FMT_AMPM = 43 };
+static const char *arrow_c_langinfo[] = {
+ "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat",
+ "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday",
+ "Jan", "Feb", "Mar", "Apr", "May", "Jun",
+ "Jul", "Aug", "Sep", "Oct", "Nov", "Dec",
+ "January", "February", "March", "April", "May", "June",
+ "July", "August", "September", "October", "November", "December",
+ "AM", "PM",
+ "%a %b %e %T %Y", "%m/%d/%y", "%H:%M:%S", "%I:%M:%S %p"};
Review Comment:
Could you mention where the values come from?
##########
cpp/src/arrow/vendored/musl/strptime.c:
##########
@@ -17,12 +17,29 @@
#undef HAVE_LANGINFO
-#ifndef _WIN32
+#if !defined(_WIN32) && !defined(ARROW_TEST_FALLBACK_LANGINFO)
Review Comment:
Why do we need this change? It seems that `ARROW_TEST_FALLBACK_LANGINFO` isn't defined.
--
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: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GH-54641: [C++] Support locale directives in the vendored strptime on Windows [arrow]
Posted by "kou (via GitHub)" <gi...@apache.org>.
kou merged PR #54656:
URL: https://github.com/apache/arrow/pull/54656
--
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: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GH-54641: [C++] Support locale directives in the vendored strptime on Windows [arrow]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #54656:
URL: https://github.com/apache/arrow/pull/54656#issuecomment-6274266606
:warning: GitHub issue #54641 **has been automatically assigned in GitHub** to PR creator.
--
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: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GH-54641: [C++] Support locale directives in the vendored strptime on Windows [arrow]
Posted by "kou (via GitHub)" <gi...@apache.org>.
kou commented on PR #54656:
URL: https://github.com/apache/arrow/pull/54656#issuecomment-6290195885
Passed: https://github.com/apache/arrow/actions/runs/39413302527/job/118599671926?pr=54656#step:13:6966
```text
'test-dplyr-funcs-datetime.R:241:3' [success]
```
I'll merge this.
--
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: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org