@@ -64,8 +64,8 @@ timestamp_t ×tamp_t::operator-=(const int64_t &delta) {
64
64
return *this ;
65
65
}
66
66
67
- TimestampCastResult Timestamp::TryConvertTimestampTZ (const char *str, idx_t len, timestamp_t &result, bool &has_offset ,
68
- string_t &tz, optional_ptr<int32_t > nanos) {
67
+ TimestampCastResult Timestamp::TryConvertTimestampTZ (const char *str, idx_t len, timestamp_t &result, bool use_offset ,
68
+ bool &has_offset, string_t &tz, optional_ptr<int32_t > nanos) {
69
69
idx_t pos;
70
70
date_t date;
71
71
dtime_t time;
@@ -118,7 +118,7 @@ TimestampCastResult Timestamp::TryConvertTimestampTZ(const char *str, idx_t len,
118
118
} else if (Timestamp::TryParseUTCOffset (str, pos, len, hh, mm, ss)) {
119
119
const int64_t delta =
120
120
hh * Interval::MICROS_PER_HOUR + mm * Interval::MICROS_PER_MINUTE + ss * Interval::MICROS_PER_SEC;
121
- if (!TrySubtractOperator::Operation (result.value , delta, result.value )) {
121
+ if (use_offset && !TrySubtractOperator::Operation (result.value , delta, result.value )) {
122
122
return TimestampCastResult::ERROR_RANGE;
123
123
}
124
124
has_offset = true ;
@@ -149,12 +149,12 @@ TimestampCastResult Timestamp::TryConvertTimestampTZ(const char *str, idx_t len,
149
149
return TimestampCastResult::SUCCESS;
150
150
}
151
151
152
- TimestampCastResult Timestamp::TryConvertTimestamp (const char *str, idx_t len, timestamp_t &result,
152
+ TimestampCastResult Timestamp::TryConvertTimestamp (const char *str, idx_t len, timestamp_t &result, bool use_offset,
153
153
optional_ptr<int32_t > nanos, bool strict) {
154
154
string_t tz (nullptr , 0 );
155
155
bool has_offset = false ;
156
156
// We don't understand TZ without an extension, so fail if one was provided.
157
- auto success = TryConvertTimestampTZ (str, len, result, has_offset, tz, nanos);
157
+ auto success = TryConvertTimestampTZ (str, len, result, use_offset, has_offset, tz, nanos);
158
158
if (success != TimestampCastResult::SUCCESS) {
159
159
return success;
160
160
}
@@ -198,7 +198,7 @@ bool Timestamp::TryFromTimestampNanos(timestamp_t input, int32_t nanos, timestam
198
198
199
199
TimestampCastResult Timestamp::TryConvertTimestamp (const char *str, idx_t len, timestamp_ns_t &result) {
200
200
int32_t nanos = 0 ;
201
- auto success = TryConvertTimestamp (str, len, result, &nanos);
201
+ auto success = TryConvertTimestamp (str, len, result, true , &nanos);
202
202
if (success != TimestampCastResult::SUCCESS) {
203
203
return success;
204
204
}
@@ -236,9 +236,9 @@ string Timestamp::RangeError(string_t str) {
236
236
return Timestamp::RangeError (str.GetString ());
237
237
}
238
238
239
- timestamp_t Timestamp::FromCString (const char *str, idx_t len, optional_ptr<int32_t > nanos) {
239
+ timestamp_t Timestamp::FromCString (const char *str, idx_t len, bool use_offset, optional_ptr<int32_t > nanos) {
240
240
timestamp_t result;
241
- switch (Timestamp::TryConvertTimestamp (str, len, result, nanos)) {
241
+ switch (Timestamp::TryConvertTimestamp (str, len, result, use_offset, nanos)) {
242
242
case TimestampCastResult::SUCCESS:
243
243
case TimestampCastResult::STRICT_UTC:
244
244
break ;
@@ -324,8 +324,8 @@ bool Timestamp::TryParseUTCOffset(const char *str, idx_t &pos, idx_t len, int &h
324
324
return true ;
325
325
}
326
326
327
- timestamp_t Timestamp::FromString (const string &str) {
328
- return Timestamp::FromCString (str.c_str (), str.size ());
327
+ timestamp_t Timestamp::FromString (const string &str, bool use_offset ) {
328
+ return Timestamp::FromCString (str.c_str (), str.size (), use_offset );
329
329
}
330
330
331
331
string Timestamp::ToString (timestamp_t timestamp) {
0 commit comments