Autonomy Software C++ 24.5.1
Welcome to the Autonomy Software repository of the Mars Rover Design Team (MRDT) at Missouri University of Science and Technology (Missouri S&T)! API reference contains the source code and other resources for the development of the autonomy software for our Mars rover. The Autonomy Software project aims to compete in the University Rover Challenge (URC) by demonstrating advanced autonomous capabilities and robust navigation algorithms.
Loading...
Searching...
No Matches
duckdb::StrpTimeFormat::ParseResult Struct Reference

Type-safe parsing argument. More...

#include <duckdb.hpp>

Collaboration diagram for duckdb::StrpTimeFormat::ParseResult:

Public Member Functions

int32_t GetMicros () const
date_t ToDate ()
dtime_t ToTime ()
int64_t ToTimeNS ()
timestamp_t ToTimestamp ()
timestamp_ns_t ToTimestampNS ()
bool TryToDate (date_t &result)
bool TryToTime (dtime_t &result)
bool TryToTimestamp (timestamp_t &result)
bool TryToTimestampNS (timestamp_ns_t &result)
DUCKDB_API string FormatError (string_t input, const string &format_specifier)

Public Attributes

int32_t data [8]
string tz
string error_message
optional_idx error_position
bool is_special
date_t special

Detailed Description

Type-safe parsing argument.

Member Function Documentation

◆ GetMicros()

int32_t duckdb::StrpTimeFormat::ParseResult::GetMicros ( ) const
231659 {
231660 return UnsafeNumericCast<int32_t>((data[6] + Interval::NANOS_PER_MICRO / 2) / Interval::NANOS_PER_MICRO);
231661}

◆ ToDate()

date_t duckdb::StrpTimeFormat::ParseResult::ToDate ( )
231648 {
231649 if (is_special) {
231650 return special;
231651 }
231652 return Date::FromDate(data[0], data[1], data[2]);
231653}
static DUCKDB_API date_t FromDate(int32_t year, int32_t month, int32_t day)
Create a Date object from a specified (year, month, day) combination.
Definition duckdb.cpp:117328

◆ ToTime()

dtime_t duckdb::StrpTimeFormat::ParseResult::ToTime ( )
231663 {
231664 int hh, mm, ss;
231665 StrfTimeSplitOffset(data[7], hh, mm, ss);
231666 return Time::FromTime(data[3] - hh, data[4] - mm, data[5] - ss, GetMicros());
231667}

◆ ToTimeNS()

int64_t duckdb::StrpTimeFormat::ParseResult::ToTimeNS ( )
231669 {
231670 int hh, mm, ss;
231671 StrfTimeSplitOffset(data[7], hh, mm, ss);
231672 return Time::ToNanoTime(data[3] - hh, data[4] - mm, data[5] - ss, data[6]);
231673}

◆ ToTimestamp()

timestamp_t duckdb::StrpTimeFormat::ParseResult::ToTimestamp ( )
231683 {
231684 if (is_special) {
231685 if (special == date_t::infinity()) {
231686 return timestamp_t::infinity();
231687 } else if (special == date_t::ninfinity()) {
231688 return timestamp_t::ninfinity();
231689 }
231690 return Timestamp::FromDatetime(special, dtime_t(0));
231691 }
231692
231693 date_t date = ToDate();
231694 dtime_t time = ToTime();
231695 return Timestamp::FromDatetime(date, time);
231696}
static DUCKDB_API timestamp_t FromDatetime(date_t date, dtime_t time)
Create a Timestamp object from a specified (date, time) combination.
Definition duckdb.cpp:129804

◆ ToTimestampNS()

timestamp_ns_t duckdb::StrpTimeFormat::ParseResult::ToTimestampNS ( )
231707 {
231708 timestamp_ns_t result;
231709 if (is_special) {
231710 if (special == date_t::infinity()) {
231711 result.value = timestamp_t::infinity().value;
231712 } else if (special == date_t::ninfinity()) {
231713 result.value = timestamp_t::ninfinity().value;
231714 } else {
231715 result.value = special.days * Interval::NANOS_PER_DAY;
231716 }
231717 } else {
231718 // Don't use rounded µs
231719 const auto date = ToDate();
231720 const auto time = ToTimeNS();
231721 if (!TryMultiplyOperator::Operation<int64_t, int64_t, int64_t>(date.days, Interval::NANOS_PER_DAY,
231722 result.value)) {
231723 throw ConversionException("Date out of nanosecond range: %d-%d-%d", data[0], data[1], data[2]);
231724 }
231725 if (!TryAddOperator::Operation<int64_t, int64_t, int64_t>(result.value, time, result.value)) {
231726 throw ConversionException("Overflow exception in date/time -> timestamp_ns conversion");
231727 }
231728 }
231729
231730 return result;
231731}

◆ TryToDate()

bool duckdb::StrpTimeFormat::ParseResult::TryToDate ( date_t & result)
231655 {
231656 return Date::TryFromDate(data[0], data[1], data[2], result);
231657}

◆ TryToTime()

bool duckdb::StrpTimeFormat::ParseResult::TryToTime ( dtime_t & result)
231675 {
231676 if (data[7]) {
231677 return false;
231678 }
231679 result = Time::FromTime(data[3], data[4], data[5], GetMicros());
231680 return true;
231681}

◆ TryToTimestamp()

bool duckdb::StrpTimeFormat::ParseResult::TryToTimestamp ( timestamp_t & result)
231698 {
231699 date_t date;
231700 if (!TryToDate(date)) {
231701 return false;
231702 }
231703 dtime_t time = ToTime();
231704 return Timestamp::TryFromDatetime(date, time, result);
231705}

◆ TryToTimestampNS()

bool duckdb::StrpTimeFormat::ParseResult::TryToTimestampNS ( timestamp_ns_t & result)
231733 {
231734 date_t date;
231735 if (!TryToDate(date)) {
231736 return false;
231737 }
231738
231739 // Don't use rounded µs
231740 const auto time = ToTimeNS();
231741 if (!TryMultiplyOperator::Operation<int64_t, int64_t, int64_t>(date.days, Interval::NANOS_PER_DAY, result.value)) {
231742 return false;
231743 }
231744 if (!TryAddOperator::Operation<int64_t, int64_t, int64_t>(result.value, time, result.value)) {
231745 return false;
231746 }
231747 return Timestamp::IsFinite(result);
231748}
static bool IsFinite(timestamp_t timestamp)
True, if the timestamp is finite, else false.
Definition duckdb.hpp:4287

◆ FormatError()

string duckdb::StrpTimeFormat::ParseResult::FormatError ( string_t input,
const string & format_specifier )
231750 {
231751 return StringUtil::Format("Could not parse string \"%s\" according to format specifier \"%s\"\n%s\nError: %s",
231752 input.GetString(), format_specifier,
231753 FormatStrpTimeError(input.GetString(), error_position), error_message);
231754}
static string Format(const string fmt_str, ARGS... params)
Format a string using printf semantics.
Definition duckdb.hpp:4002
string format_specifier
The full format specifier, for error messages.
Definition duckdb.hpp:46098

The documentation for this struct was generated from the following files: