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::StringCastTZ Struct Reference

Temporary casting for Time Zone types. TODO: turn casting into functions. More...

Public Member Functions

template<>
duckdb::string_t Operation (date_t input, Vector &result)
template<>
duckdb::string_t Operation (dtime_tz_t input, Vector &result)
template<>
duckdb::string_t Operation (timestamp_t input, Vector &result)
template<>
string_t Operation (dtime_tz_t input, Vector &vector)
template<>
string_t Operation (timestamp_t input, Vector &vector)

Static Public Member Functions

template<typename SRC>
static string_t Operation (SRC input, Vector &vector)

Detailed Description

Temporary casting for Time Zone types. TODO: turn casting into functions.

Member Function Documentation

◆ Operation() [1/3]

template<typename SRC>
string_t duckdb::StringCastTZ::Operation ( SRC input,
Vector & vector )
inlinestatic
85443 {
85444 return StringCast::Operation(input, vector);
85445 }

◆ Operation() [2/3]

template<>
string_t duckdb::StringCastTZ::Operation ( dtime_tz_t input,
Vector & vector )
91929 {
91930 int32_t time[4];
91931 Time::Convert(input.time(), time[0], time[1], time[2], time[3]);
91932
91933 char micro_buffer[10] = {};
91934 const auto time_length = TimeToStringCast::Length(time, micro_buffer);
91935 idx_t length = time_length;
91936
91937 const auto offset = input.offset();
91938 const bool negative = (offset < 0);
91939 ++length;
91940
91941 auto ss = std::abs(offset);
91942 const auto hh = ss / Interval::SECS_PER_HOUR;
91943
91944 const auto hh_length = UnsafeNumericCast<idx_t>((hh < 100) ? 2 : NumericHelper::UnsignedLength(uint32_t(hh)));
91945 length += hh_length;
91946
91947 ss %= Interval::SECS_PER_HOUR;
91948 const auto mm = ss / Interval::SECS_PER_MINUTE;
91949 if (mm) {
91950 length += 3;
91951 }
91952
91953 ss %= Interval::SECS_PER_MINUTE;
91954 if (ss) {
91955 length += 3;
91956 }
91957
91958 string_t result = StringVector::EmptyString(vector, length);
91959 auto data = result.GetDataWriteable();
91960
91961 idx_t pos = 0;
91962 TimeToStringCast::Format(data + pos, time_length, time, micro_buffer);
91963 pos += time_length;
91964
91965 data[pos++] = negative ? '-' : '+';
91966 if (hh < 100) {
91967 TimeToStringCast::FormatTwoDigits(data + pos, hh);
91968 } else {
91969 NumericHelper::FormatUnsigned(hh, data + pos + hh_length);
91970 }
91971 pos += hh_length;
91972
91973 if (mm) {
91974 data[pos++] = ':';
91975 TimeToStringCast::FormatTwoDigits(data + pos, mm);
91976 pos += 2;
91977 }
91978
91979 if (ss) {
91980 data[pos++] = ':';
91981 TimeToStringCast::FormatTwoDigits(data + pos, ss);
91982 pos += 2;
91983 }
91984
91985 result.Finalize();
91986 return result;
91987}
static DUCKDB_API void Convert(dtime_t time, int32_t &out_hour, int32_t &out_min, int32_t &out_sec, int32_t &out_micros)
Extract the time from a given timestamp object.
Definition duckdb.cpp:129382
::uint32_t uint32_t
::int32_t int32_t
uint64_t idx_t
a saner size_t for loop indices etc
Definition duckdb.hpp:237
static DUCKDB_API string_t EmptyString(Vector &vector, idx_t len)
Definition duckdb.cpp:137942

◆ Operation() [3/3]

template<>
string_t duckdb::StringCastTZ::Operation ( timestamp_t input,
Vector & vector )
91990 {
91991 if (input == timestamp_t::infinity()) {
91992 return StringVector::AddString(vector, Date::PINF.str);
91993 }
91994 if (input == timestamp_t::ninfinity()) {
91995 return StringVector::AddString(vector, Date::NINF.str);
91996 }
91997
91998 date_t date_entry;
91999 dtime_t time_entry;
92000 Timestamp::Convert(input, date_entry, time_entry);
92001
92002 int32_t date[3], time[4];
92003 Date::Convert(date_entry, date[0], date[1], date[2]);
92004 Time::Convert(time_entry, time[0], time[1], time[2], time[3]);
92005
92006 // format for timestamptz is DATE TIME+00 (separated by space)
92007 idx_t year_length;
92008 bool add_bc;
92009 char micro_buffer[6] = {};
92010 const idx_t date_length = DateToStringCast::Length(date, year_length, add_bc);
92011 const idx_t time_length = TimeToStringCast::Length(time, micro_buffer);
92012 const idx_t length = date_length + 1 + time_length + 3;
92013
92014 string_t result = StringVector::EmptyString(vector, length);
92015 auto data = result.GetDataWriteable();
92016
92017 idx_t pos = 0;
92018 DateToStringCast::Format(data + pos, date, year_length, add_bc);
92019 pos += date_length;
92020 data[pos++] = ' ';
92021 TimeToStringCast::Format(data + pos, time_length, time, micro_buffer);
92022 pos += time_length;
92023 data[pos++] = '+';
92024 data[pos++] = '0';
92025 data[pos++] = '0';
92026
92027 result.Finalize();
92028 return result;
92029}
static DUCKDB_API void Convert(date_t date, int32_t &out_year, int32_t &out_month, int32_t &out_day)
Extract the year, month and day from a given date object.
Definition duckdb.cpp:117272
static DUCKDB_API void Convert(timestamp_t date, date_t &out_date, dtime_t &out_time)
Extract the date and time from a given timestamp object.
Definition duckdb.cpp:129812
static DUCKDB_API string_t AddString(Vector &vector, const char *data, idx_t len)
Add a string to the string heap of the vector (auxiliary data).
Definition duckdb.cpp:137889

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