| 421 | : type(type), expect_timezone(!type.timezone().empty()) {} |
| 422 | template <typename OutValue, typename Arg0Value> |
| 423 | OutValue Call(KernelContext*, Arg0Value val, Status* st) const { |
| 424 | OutValue result = 0; |
| 425 | bool zone_offset_present = false; |
| 426 | if (ARROW_PREDICT_FALSE(!ParseTimestampISO8601(val.data(), val.size(), type.unit(), |
| 427 | &result, &zone_offset_present))) { |
| 428 | *st = Status::Invalid("Failed to parse string: '", val, "' as a scalar of type ", |
| 429 | type.ToString()); |
| 430 | } |
| 431 | if (zone_offset_present != expect_timezone) { |
| 432 | if (expect_timezone) { |
| 433 | *st = Status::Invalid( |
| 434 | "Failed to parse string: '", val, "' as a scalar of type ", type.ToString(), |
| 435 | ": expected a zone offset. If these timestamps " |
| 436 | "are in local time, cast to timestamp without timezone, then " |
| 437 | "call assume_timezone."); |
| 438 | } else { |
| 439 | *st = Status::Invalid("Failed to parse string: '", val, "' as a scalar of type ", |
| 440 | type.ToString(), ": expected no zone offset."); |
| 441 | } |
| 442 | } |
| 443 | return result; |
| 444 | } |
| 445 | |
| 446 | const TimestampType& type; |
| 447 | bool expect_timezone; |