Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 22 additions & 21 deletions cpp/src/arrow/compute/kernels/scalar_temporal_binary.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
#include "arrow/util/checked_cast.h"
#include "arrow/util/logging_internal.h"
#include "arrow/util/time.h"
#include "arrow/vendored/datetime.h"

namespace arrow {

Expand All @@ -37,28 +36,30 @@ using internal::checked_pointer_cast;
namespace compute {
namespace internal {

namespace chrono = arrow::internal::chrono;

namespace {

using arrow_vendored::date::days;
using arrow_vendored::date::floor;
using arrow_vendored::date::hh_mm_ss;
using arrow_vendored::date::local_days;
using arrow_vendored::date::local_time;
using arrow_vendored::date::sys_days;
using arrow_vendored::date::sys_time;
using arrow_vendored::date::trunc;
using arrow_vendored::date::weekday;
using arrow_vendored::date::weeks;
using arrow_vendored::date::year_month_day;
using arrow_vendored::date::year_month_weekday;
using arrow_vendored::date::years;
using arrow_vendored::date::literals::dec;
using arrow_vendored::date::literals::jan;
using arrow_vendored::date::literals::last;
using arrow_vendored::date::literals::mon;
using arrow_vendored::date::literals::sun;
using arrow_vendored::date::literals::thu;
using arrow_vendored::date::literals::wed;
using chrono::days;
using chrono::floor;
using chrono::hh_mm_ss;
using chrono::local_days;
using chrono::local_time;
using chrono::sys_days;
using chrono::sys_time;
using chrono::trunc;
using chrono::weekday;
using chrono::weeks;
using chrono::year_month_day;
using chrono::year_month_weekday;
using chrono::years;
using chrono::literals::dec;
using chrono::literals::jan;
using chrono::literals::last;
using chrono::literals::mon;
using chrono::literals::sun;
using chrono::literals::thu;
using chrono::literals::wed;
using internal::applicator::ScalarBinaryNotNullStatefulEqualTypes;

using DayOfWeekState = OptionsWrapper<DayOfWeekOptions>;
Expand Down
5 changes: 5 additions & 0 deletions cpp/src/arrow/compute/kernels/scalar_temporal_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include "arrow/type_fwd.h"
#include "arrow/type_traits.h"
#include "arrow/util/checked_cast.h"
#include "arrow/util/chrono_internal.h" // for ARROW_USE_STD_CHRONO
#include "arrow/util/formatting.h"
#include "arrow/util/logging_internal.h"

Expand All @@ -38,6 +39,10 @@ using internal::StringFormatter;

namespace compute {

TEST(ChronoConfig, LogChronoBackend) {
std::cout << "ARROW_USE_STD_CHRONO=" << ARROW_USE_STD_CHRONO << std::endl;
}

class ScalarTemporalTest : public ::testing::Test {
public:
const char* date32s =
Expand Down
74 changes: 36 additions & 38 deletions cpp/src/arrow/compute/kernels/scalar_temporal_unary.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
#include "arrow/util/logging_internal.h"
#include "arrow/util/time.h"
#include "arrow/util/value_parsing.h"
#include "arrow/vendored/datetime.h"

namespace arrow {

Expand All @@ -38,34 +37,36 @@ using internal::checked_pointer_cast;

namespace compute::internal {

namespace chrono = arrow::internal::chrono;

namespace {

using arrow_vendored::date::ceil;
using arrow_vendored::date::days;
using arrow_vendored::date::floor;
using arrow_vendored::date::hh_mm_ss;
using arrow_vendored::date::local_days;
using arrow_vendored::date::local_time;
using arrow_vendored::date::locate_zone;
using arrow_vendored::date::Monday;
using arrow_vendored::date::months;
using arrow_vendored::date::round;
using arrow_vendored::date::Sunday;
using arrow_vendored::date::sys_time;
using arrow_vendored::date::trunc;
using arrow_vendored::date::weekday;
using arrow_vendored::date::weeks;
using arrow_vendored::date::year;
using arrow_vendored::date::year_month_day;
using arrow_vendored::date::year_month_weekday;
using arrow_vendored::date::years;
using arrow_vendored::date::literals::dec;
using arrow_vendored::date::literals::jan;
using arrow_vendored::date::literals::last;
using arrow_vendored::date::literals::mon;
using arrow_vendored::date::literals::sun;
using arrow_vendored::date::literals::thu;
using arrow_vendored::date::literals::wed;
using chrono::ceil;
using chrono::days;
using chrono::floor;
using chrono::hh_mm_ss;
using chrono::local_days;
using chrono::local_time;
using chrono::locate_zone;
using chrono::Monday;
using chrono::months;
using chrono::round;
using chrono::Sunday;
using chrono::sys_time;
using chrono::trunc;
using chrono::weekday;
using chrono::weeks;
using chrono::year;
using chrono::year_month_day;
using chrono::year_month_weekday;
using chrono::years;
using chrono::literals::dec;
using chrono::literals::jan;
using chrono::literals::last;
using chrono::literals::mon;
using chrono::literals::sun;
using chrono::literals::thu;
using chrono::literals::wed;
using std::chrono::duration_cast;
using std::chrono::hours;
using std::chrono::minutes;
Expand Down Expand Up @@ -525,8 +526,8 @@ struct Week {
}

Localizer localizer_;
arrow_vendored::date::weekday wd_;
arrow_vendored::date::days days_offset_;
chrono::weekday wd_;
chrono::days days_offset_;
const bool count_from_zero_;
const bool first_week_is_fully_in_year_;
};
Expand Down Expand Up @@ -1379,35 +1380,32 @@ struct AssumeTimezone {
T Call(KernelContext*, Arg0 arg, Status* st) const {
try {
return get_local_time<T, Arg0>(arg, &tz_);
} catch (const arrow_vendored::date::nonexistent_local_time& e) {
} catch (const chrono::nonexistent_local_time& e) {
switch (options.nonexistent) {
case AssumeTimezoneOptions::Nonexistent::NONEXISTENT_RAISE: {
*st = Status::Invalid("Timestamp doesn't exist in timezone '", options.timezone,
"': ", e.what());
return arg;
}
case AssumeTimezoneOptions::Nonexistent::NONEXISTENT_EARLIEST: {
return get_local_time<T, Arg0>(arg, arrow_vendored::date::choose::latest,
&tz_) -
1;
return get_local_time<T, Arg0>(arg, chrono::choose::latest, &tz_) - 1;
}
case AssumeTimezoneOptions::Nonexistent::NONEXISTENT_LATEST: {
return get_local_time<T, Arg0>(arg, arrow_vendored::date::choose::latest, &tz_);
return get_local_time<T, Arg0>(arg, chrono::choose::latest, &tz_);
}
}
} catch (const arrow_vendored::date::ambiguous_local_time& e) {
} catch (const chrono::ambiguous_local_time& e) {
switch (options.ambiguous) {
case AssumeTimezoneOptions::Ambiguous::AMBIGUOUS_RAISE: {
*st = Status::Invalid("Timestamp is ambiguous in timezone '", options.timezone,
"': ", e.what());
return arg;
}
case AssumeTimezoneOptions::Ambiguous::AMBIGUOUS_EARLIEST: {
return get_local_time<T, Arg0>(arg, arrow_vendored::date::choose::earliest,
&tz_);
return get_local_time<T, Arg0>(arg, chrono::choose::earliest, &tz_);
}
case AssumeTimezoneOptions::Ambiguous::AMBIGUOUS_LATEST: {
return get_local_time<T, Arg0>(arg, arrow_vendored::date::choose::latest, &tz_);
return get_local_time<T, Arg0>(arg, chrono::choose::latest, &tz_);
}
}
}
Expand Down
31 changes: 17 additions & 14 deletions cpp/src/arrow/compute/kernels/temporal_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,22 @@
#include "arrow/util/value_parsing.h"

namespace arrow::compute::internal {

namespace chrono = arrow::internal::chrono;

using arrow::internal::checked_cast;
using arrow::internal::OffsetZone;
using arrow_vendored::date::choose;
using arrow_vendored::date::days;
using arrow_vendored::date::floor;
using arrow_vendored::date::local_days;
using arrow_vendored::date::local_time;
using arrow_vendored::date::locate_zone;
using arrow_vendored::date::sys_days;
using arrow_vendored::date::sys_time;
using arrow_vendored::date::time_zone;
using arrow_vendored::date::year_month_day;
using arrow_vendored::date::zoned_time;
using chrono::choose;
using chrono::days;
using chrono::floor;
using chrono::local_days;
using chrono::local_time;
using chrono::locate_zone;
using chrono::sys_days;
using chrono::sys_time;
using chrono::time_zone;
using chrono::year_month_day;
using chrono::zoned_time;
using std::chrono::duration_cast;

// https://howardhinnant.github.io/date/tz.html#Examples
Expand Down Expand Up @@ -148,10 +151,10 @@ struct ZonedLocalizer {

try {
return ApplyTimeZone(tz_, lt, std::nullopt, local_to_sys_time);
} catch (const arrow_vendored::date::nonexistent_local_time& e) {
} catch (const chrono::nonexistent_local_time& e) {
*st = Status::Invalid("Local time does not exist: ", e.what());
return Duration{0};
} catch (const arrow_vendored::date::ambiguous_local_time& e) {
} catch (const chrono::ambiguous_local_time& e) {
*st = Status::Invalid("Local time is ambiguous: ", e.what());
return Duration{0};
}
Expand Down Expand Up @@ -179,7 +182,7 @@ struct TimestampFormatter {
const auto timepoint = sys_time<Duration>(Duration{arg});
auto format_zoned_time = [&](auto&& zt) {
try {
arrow_vendored::date::to_stream(bufstream, format, zt);
chrono::to_stream(bufstream, format, zt);
return Status::OK();
} catch (const std::runtime_error& ex) {
bufstream.clear();
Expand Down
Loading
Loading