This is an automated email from the ASF dual-hosted git repository.
dongjoon pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/orc.git
The following commit(s) were added to refs/heads/main by this push:
new d908f96cd ORC-2021: Fallback to UTC when /etc/localtime does not exist
d908f96cd is described below
commit d908f96cd07175e8f0c93e5070137c171e503c17
Author: Jakub Klinkovský <[email protected]>
AuthorDate: Fri Oct 10 12:51:09 2025 -0700
ORC-2021: Fallback to UTC when /etc/localtime does not exist
### What changes were proposed in this pull request?
This PR aims to fallback to `UTC` when `/etc/localtime` doesn't exist.
### Why are the changes needed?
To handle OSes which doesn't have it.
### How was this patch tested?
Pass the CIs.
### Was this patch authored or co-authored using generative AI tooling?
No.
Closes #2225
Closes #2432 from lahwaacz/timezone-fallback.
Authored-by: Jakub Klinkovský <[email protected]>
Signed-off-by: Dongjoon Hyun <[email protected]>
---
c++/src/Timezone.cc | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/c++/src/Timezone.cc b/c++/src/Timezone.cc
index bc56efa0d..6c3f58c07 100644
--- a/c++/src/Timezone.cc
+++ b/c++/src/Timezone.cc
@@ -28,6 +28,12 @@
#include <map>
#include <sstream>
+#ifndef _MSC_VER
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <unistd.h>
+#endif
+
namespace orc {
// default location of the timezone files
@@ -780,6 +786,17 @@ namespace orc {
#ifdef _MSC_VER
return getTimezoneByName("UTC");
#else
+ // The absence of LOCAL_TIMEZONE means UTC conventionally
+ {
+ std::string filename(LOCAL_TIMEZONE_DIR);
+ filename += "/";
+ filename += LOCAL_TIMEZONE;
+ struct stat _ignored;
+ if (stat(filename.c_str(), &_ignored) == -1) {
+ return getTimezoneByName("UTC");
+ }
+ }
+
return getTimezoneByFilename(LOCAL_TIMEZONE_DIR, LOCAL_TIMEZONE);
#endif
}