Skip to content

Commit 4ea1a45

Browse files
committed
first draft
1 parent 6a481e5 commit 4ea1a45

File tree

5 files changed

+478
-87
lines changed

5 files changed

+478
-87
lines changed

cpp/src/arrow/compute/kernels/scalar_temporal_binary.cc

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
#include "arrow/util/checked_cast.h"
2828
#include "arrow/util/logging_internal.h"
2929
#include "arrow/util/time.h"
30-
#include "arrow/vendored/datetime.h"
3130

3231
namespace arrow {
3332

@@ -37,28 +36,30 @@ using internal::checked_pointer_cast;
3736
namespace compute {
3837
namespace internal {
3938

39+
namespace chrono = arrow::internal::chrono;
40+
4041
namespace {
4142

42-
using arrow_vendored::date::days;
43-
using arrow_vendored::date::floor;
44-
using arrow_vendored::date::hh_mm_ss;
45-
using arrow_vendored::date::local_days;
46-
using arrow_vendored::date::local_time;
47-
using arrow_vendored::date::sys_days;
48-
using arrow_vendored::date::sys_time;
49-
using arrow_vendored::date::trunc;
50-
using arrow_vendored::date::weekday;
51-
using arrow_vendored::date::weeks;
52-
using arrow_vendored::date::year_month_day;
53-
using arrow_vendored::date::year_month_weekday;
54-
using arrow_vendored::date::years;
55-
using arrow_vendored::date::literals::dec;
56-
using arrow_vendored::date::literals::jan;
57-
using arrow_vendored::date::literals::last;
58-
using arrow_vendored::date::literals::mon;
59-
using arrow_vendored::date::literals::sun;
60-
using arrow_vendored::date::literals::thu;
61-
using arrow_vendored::date::literals::wed;
43+
using chrono::days;
44+
using chrono::floor;
45+
using chrono::hh_mm_ss;
46+
using chrono::local_days;
47+
using chrono::local_time;
48+
using chrono::sys_days;
49+
using chrono::sys_time;
50+
using chrono::trunc;
51+
using chrono::weekday;
52+
using chrono::weeks;
53+
using chrono::year_month_day;
54+
using chrono::year_month_weekday;
55+
using chrono::years;
56+
using chrono::literals::dec;
57+
using chrono::literals::jan;
58+
using chrono::literals::last;
59+
using chrono::literals::mon;
60+
using chrono::literals::sun;
61+
using chrono::literals::thu;
62+
using chrono::literals::wed;
6263
using internal::applicator::ScalarBinaryNotNullStatefulEqualTypes;
6364

6465
using DayOfWeekState = OptionsWrapper<DayOfWeekOptions>;

cpp/src/arrow/compute/kernels/scalar_temporal_unary.cc

Lines changed: 36 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
#include "arrow/util/logging_internal.h"
3030
#include "arrow/util/time.h"
3131
#include "arrow/util/value_parsing.h"
32-
#include "arrow/vendored/datetime.h"
3332

3433
namespace arrow {
3534

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

3938
namespace compute::internal {
4039

40+
namespace chrono = arrow::internal::chrono;
41+
4142
namespace {
4243

43-
using arrow_vendored::date::ceil;
44-
using arrow_vendored::date::days;
45-
using arrow_vendored::date::floor;
46-
using arrow_vendored::date::hh_mm_ss;
47-
using arrow_vendored::date::local_days;
48-
using arrow_vendored::date::local_time;
49-
using arrow_vendored::date::locate_zone;
50-
using arrow_vendored::date::Monday;
51-
using arrow_vendored::date::months;
52-
using arrow_vendored::date::round;
53-
using arrow_vendored::date::Sunday;
54-
using arrow_vendored::date::sys_time;
55-
using arrow_vendored::date::trunc;
56-
using arrow_vendored::date::weekday;
57-
using arrow_vendored::date::weeks;
58-
using arrow_vendored::date::year;
59-
using arrow_vendored::date::year_month_day;
60-
using arrow_vendored::date::year_month_weekday;
61-
using arrow_vendored::date::years;
62-
using arrow_vendored::date::literals::dec;
63-
using arrow_vendored::date::literals::jan;
64-
using arrow_vendored::date::literals::last;
65-
using arrow_vendored::date::literals::mon;
66-
using arrow_vendored::date::literals::sun;
67-
using arrow_vendored::date::literals::thu;
68-
using arrow_vendored::date::literals::wed;
44+
using chrono::ceil;
45+
using chrono::days;
46+
using chrono::floor;
47+
using chrono::hh_mm_ss;
48+
using chrono::local_days;
49+
using chrono::local_time;
50+
using chrono::locate_zone;
51+
using chrono::Monday;
52+
using chrono::months;
53+
using chrono::round;
54+
using chrono::Sunday;
55+
using chrono::sys_time;
56+
using chrono::trunc;
57+
using chrono::weekday;
58+
using chrono::weeks;
59+
using chrono::year;
60+
using chrono::year_month_day;
61+
using chrono::year_month_weekday;
62+
using chrono::years;
63+
using chrono::literals::dec;
64+
using chrono::literals::jan;
65+
using chrono::literals::last;
66+
using chrono::literals::mon;
67+
using chrono::literals::sun;
68+
using chrono::literals::thu;
69+
using chrono::literals::wed;
6970
using std::chrono::duration_cast;
7071
using std::chrono::hours;
7172
using std::chrono::minutes;
@@ -525,8 +526,8 @@ struct Week {
525526
}
526527

527528
Localizer localizer_;
528-
arrow_vendored::date::weekday wd_;
529-
arrow_vendored::date::days days_offset_;
529+
chrono::weekday wd_;
530+
chrono::days days_offset_;
530531
const bool count_from_zero_;
531532
const bool first_week_is_fully_in_year_;
532533
};
@@ -1379,35 +1380,32 @@ struct AssumeTimezone {
13791380
T Call(KernelContext*, Arg0 arg, Status* st) const {
13801381
try {
13811382
return get_local_time<T, Arg0>(arg, &tz_);
1382-
} catch (const arrow_vendored::date::nonexistent_local_time& e) {
1383+
} catch (const chrono::nonexistent_local_time& e) {
13831384
switch (options.nonexistent) {
13841385
case AssumeTimezoneOptions::Nonexistent::NONEXISTENT_RAISE: {
13851386
*st = Status::Invalid("Timestamp doesn't exist in timezone '", options.timezone,
13861387
"': ", e.what());
13871388
return arg;
13881389
}
13891390
case AssumeTimezoneOptions::Nonexistent::NONEXISTENT_EARLIEST: {
1390-
return get_local_time<T, Arg0>(arg, arrow_vendored::date::choose::latest,
1391-
&tz_) -
1392-
1;
1391+
return get_local_time<T, Arg0>(arg, chrono::choose::latest, &tz_) - 1;
13931392
}
13941393
case AssumeTimezoneOptions::Nonexistent::NONEXISTENT_LATEST: {
1395-
return get_local_time<T, Arg0>(arg, arrow_vendored::date::choose::latest, &tz_);
1394+
return get_local_time<T, Arg0>(arg, chrono::choose::latest, &tz_);
13961395
}
13971396
}
1398-
} catch (const arrow_vendored::date::ambiguous_local_time& e) {
1397+
} catch (const chrono::ambiguous_local_time& e) {
13991398
switch (options.ambiguous) {
14001399
case AssumeTimezoneOptions::Ambiguous::AMBIGUOUS_RAISE: {
14011400
*st = Status::Invalid("Timestamp is ambiguous in timezone '", options.timezone,
14021401
"': ", e.what());
14031402
return arg;
14041403
}
14051404
case AssumeTimezoneOptions::Ambiguous::AMBIGUOUS_EARLIEST: {
1406-
return get_local_time<T, Arg0>(arg, arrow_vendored::date::choose::earliest,
1407-
&tz_);
1405+
return get_local_time<T, Arg0>(arg, chrono::choose::earliest, &tz_);
14081406
}
14091407
case AssumeTimezoneOptions::Ambiguous::AMBIGUOUS_LATEST: {
1410-
return get_local_time<T, Arg0>(arg, arrow_vendored::date::choose::latest, &tz_);
1408+
return get_local_time<T, Arg0>(arg, chrono::choose::latest, &tz_);
14111409
}
14121410
}
14131411
}

cpp/src/arrow/compute/kernels/temporal_internal.h

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -26,19 +26,22 @@
2626
#include "arrow/util/value_parsing.h"
2727

2828
namespace arrow::compute::internal {
29+
30+
namespace chrono = arrow::internal::chrono;
31+
2932
using arrow::internal::checked_cast;
3033
using arrow::internal::OffsetZone;
31-
using arrow_vendored::date::choose;
32-
using arrow_vendored::date::days;
33-
using arrow_vendored::date::floor;
34-
using arrow_vendored::date::local_days;
35-
using arrow_vendored::date::local_time;
36-
using arrow_vendored::date::locate_zone;
37-
using arrow_vendored::date::sys_days;
38-
using arrow_vendored::date::sys_time;
39-
using arrow_vendored::date::time_zone;
40-
using arrow_vendored::date::year_month_day;
41-
using arrow_vendored::date::zoned_time;
34+
using chrono::choose;
35+
using chrono::days;
36+
using chrono::floor;
37+
using chrono::local_days;
38+
using chrono::local_time;
39+
using chrono::locate_zone;
40+
using chrono::sys_days;
41+
using chrono::sys_time;
42+
using chrono::time_zone;
43+
using chrono::year_month_day;
44+
using chrono::zoned_time;
4245
using std::chrono::duration_cast;
4346

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

149152
try {
150153
return ApplyTimeZone(tz_, lt, std::nullopt, local_to_sys_time);
151-
} catch (const arrow_vendored::date::nonexistent_local_time& e) {
154+
} catch (const chrono::nonexistent_local_time& e) {
152155
*st = Status::Invalid("Local time does not exist: ", e.what());
153156
return Duration{0};
154-
} catch (const arrow_vendored::date::ambiguous_local_time& e) {
157+
} catch (const chrono::ambiguous_local_time& e) {
155158
*st = Status::Invalid("Local time is ambiguous: ", e.what());
156159
return Duration{0};
157160
}
@@ -179,7 +182,7 @@ struct TimestampFormatter {
179182
const auto timepoint = sys_time<Duration>(Duration{arg});
180183
auto format_zoned_time = [&](auto&& zt) {
181184
try {
182-
arrow_vendored::date::to_stream(bufstream, format, zt);
185+
chrono::to_stream(bufstream, format, zt);
183186
return Status::OK();
184187
} catch (const std::runtime_error& ex) {
185188
bufstream.clear();

0 commit comments

Comments
 (0)