Skip to content

Commit

Permalink
GH-44455: [C++] Update vendored date to 3.0.3 (#44482)
Browse files Browse the repository at this point in the history
### Rationale for this change

IANA tzdata changed its data format. So we need to update vendored date to parse it.

### What changes are included in this PR?

Update vendored date to 3.0.3.

Update script is added. So all our changes are automated now.

### Are these changes tested?

Yes.

### Are there any user-facing changes?

Yes.
* GitHub Issue: #44455

Authored-by: Sutou Kouhei <kou@clear-code.com>
Signed-off-by: Sutou Kouhei <kou@clear-code.com>
  • Loading branch information
kou authored and amoeba committed Nov 13, 2024
1 parent 90bfa2c commit ac81eed
Show file tree
Hide file tree
Showing 14 changed files with 437 additions and 142 deletions.
2 changes: 1 addition & 1 deletion ci/appveyor-cpp-build.bat
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ set PARQUET_HOME=%CONDA_PREFIX%\Library

@rem Download IANA Timezone Database to a non-standard location to
@rem test the configurability of the timezone database path
curl https://data.iana.org/time-zones/releases/tzdata2021e.tar.gz --output tzdata.tar.gz || exit /B
curl https://data.iana.org/time-zones/releases/tzdata2024b.tar.gz --output tzdata.tar.gz || exit /B
mkdir %USERPROFILE%\Downloads\test\tzdata
tar --extract --file tzdata.tar.gz --directory %USERPROFILE%\Downloads\test\tzdata
curl https://raw.githubusercontent.com/unicode-org/cldr/master/common/supplemental/windowsZones.xml ^
Expand Down
4 changes: 2 additions & 2 deletions cpp/src/arrow/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,7 @@ endif()

set(ARROW_VENDORED_SRCS
vendored/base64.cpp
vendored/datetime/tz.cpp
vendored/datetime.cpp
vendored/double-conversion/bignum-dtoa.cc
vendored/double-conversion/bignum.cc
vendored/double-conversion/cached-powers.cc
Expand Down Expand Up @@ -488,7 +488,7 @@ set(ARROW_VENDORED_SRCS
if(APPLE)
list(APPEND ARROW_VENDORED_SRCS vendored/datetime/ios.mm)
endif()
set_source_files_properties(vendored/datetime/tz.cpp
set_source_files_properties(vendored/datetime.cpp
PROPERTIES SKIP_PRECOMPILE_HEADERS ON
SKIP_UNITY_BUILD_INCLUSION ON)
arrow_add_object_library(ARROW_VENDORED ${ARROW_VENDORED_SRCS})
Expand Down
19 changes: 19 additions & 0 deletions cpp/src/arrow/vendored/datetime.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.

#include "datetime/visibility.h"
#include "datetime/tz.cpp"
7 changes: 4 additions & 3 deletions cpp/src/arrow/vendored/datetime.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@

#pragma once

#include "arrow/vendored/datetime/date.h" // IWYU pragma: export
#include "arrow/vendored/datetime/tz.h" // IWYU pragma: export
#include "arrow/vendored/datetime/visibility.h" // IWYU pragma: export
#include "arrow/vendored/datetime/date.h" // IWYU pragma: export
#include "arrow/vendored/datetime/tz.h" // IWYU pragma: export

// Can be defined by date.h.
#ifdef NOEXCEPT
#undef NOEXCEPT
# undef NOEXCEPT
#endif
12 changes: 8 additions & 4 deletions cpp/src/arrow/vendored/datetime/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,16 @@ copies or substantial portions of the Software.
Sources for datetime are adapted from Howard Hinnant's date library
(https://github.com/HowardHinnant/date).

Sources are taken from changeset 1ead6715dec030d340a316c927c877a3c4e5a00c
Sources are taken from changeset 5bdb7e6f31fac909c090a46dbd9fea27b6e609a4
of the above project.

The following changes are made:
- fix internal inclusion paths (from "date/xxx.h" to simply "xxx.h")
- enclose the `date` namespace inside the `arrow_vendored` namespace
- include a custom "visibility.h" header from "tz.cpp" for proper DLL
exports on Windows
- disable curl-based database downloading in "tz.h"

## How to update

```console
$ cd cpp/src/arrow/vendored/datetime
$ ./update.sh 3.0.3
```
7 changes: 2 additions & 5 deletions cpp/src/arrow/vendored/datetime/date.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,7 @@
# pragma warning(disable : 4127)
#endif

namespace arrow_vendored
{
namespace date
namespace arrow_vendored::date
{

//---------------+
Expand Down Expand Up @@ -8234,8 +8232,7 @@ operator<<(std::basic_ostream<CharT, Traits>& os,
detail::get_units<CharT>(typename Period::type{});
}

} // namespace date
} // namespace arrow_vendored
} // namespace arrow_vendored::date

#ifdef _MSC_VER
# pragma warning(pop)
Expand Down
7 changes: 2 additions & 5 deletions cpp/src/arrow/vendored/datetime/ios.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,7 @@
# if TARGET_OS_IPHONE
# include <string>

namespace arrow_vendored
{
namespace date
namespace arrow_vendored::date
{
namespace iOSUtils
{
Expand All @@ -43,8 +41,7 @@
std::string get_current_timezone();

} // namespace iOSUtils
} // namespace date
} // namespace arrow_vendored
} // namespace arrow_vendored::date

# endif // TARGET_OS_IPHONE
#else // !__APPLE__
Expand Down
7 changes: 2 additions & 5 deletions cpp/src/arrow/vendored/datetime/ios.mm
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,7 @@
#define TAR_SIZE_POSITION 124
#define TAR_SIZE_SIZE 12

namespace arrow_vendored
{
namespace date
namespace arrow_vendored::date
{
namespace iOSUtils
{
Expand Down Expand Up @@ -334,7 +332,6 @@ bool writeFile(const std::string &tzdataPath, const std::string &fileName,
}

} // namespace iOSUtils
} // namespace date
} // namespace arrow_vendored
} // namespace arrow_vendored::date

#endif // TARGET_OS_IPHONE
Loading

0 comments on commit ac81eed

Please sign in to comment.