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

Static Public Member Functions

static idx_t YearLength (int32_t &year, idx_t &year_length, bool &add_bc)
 
static idx_t Length (int32_t date[], idx_t &year_length, bool &add_bc)
 
static void FormatComponent (char *&ptr, int32_t number)
 
static void Format (char *data, int32_t year, int32_t month, int32_t day, idx_t year_length, bool add_bc)
 
static void Format (char *data, int32_t date[], idx_t year_length, bool add_bc)
 

Member Function Documentation

◆ YearLength()

static idx_t duckdb::DateToStringCast::YearLength ( int32_t year,
idx_t year_length,
bool &  add_bc 
)
inlinestatic
19881 {
19882 // format is YYYY-MM-DD with optional (BC) at the end
19883 // regular length is 10
19884 idx_t length = 6;
19885 year_length = 4;
19886 add_bc = false;
19887 if (year <= 0) {
19888 // add (BC) suffix
19889 length += 5;
19890 year = -year + 1;
19891 add_bc = true;
19892 }
19893
19894 // potentially add extra characters depending on length of year
19895 year_length += year >= 10000;
19896 year_length += year >= 100000;
19897 year_length += year >= 1000000;
19898 year_length += year >= 10000000;
19899 length += year_length;
19900 return length;
19901 }

◆ Length()

static idx_t duckdb::DateToStringCast::Length ( int32_t  date[],
idx_t year_length,
bool &  add_bc 
)
inlinestatic
19903 {
19904 return YearLength(date[0], year_length, add_bc);
19905 }

◆ FormatComponent()

static void duckdb::DateToStringCast::FormatComponent ( char *&  ptr,
int32_t  number 
)
inlinestatic
19907 {
19908 ptr[0] = '-';
19909 if (number < 10) {
19910 ptr[1] = '0';
19911 ptr[2] = UnsafeNumericCast<char>('0' + number);
19912 } else {
19913 auto index = UnsafeNumericCast<idx_t>(number * 2);
19914 ptr[1] = duckdb_fmt::internal::data::digits[index];
19915 ptr[2] = duckdb_fmt::internal::data::digits[index + 1];
19916 }
19917 ptr += 3;
19918 }
index

◆ Format() [1/2]

static void duckdb::DateToStringCast::Format ( char data,
int32_t  year,
int32_t  month,
int32_t  day,
idx_t  year_length,
bool  add_bc 
)
inlinestatic
19920 {
19921 // now we write the string, first write the year
19922 auto endptr = data + year_length;
19923 endptr = NumericHelper::FormatUnsigned(year, endptr);
19924 // add optional leading zeros
19925 while (endptr > data) {
19926 *--endptr = '0';
19927 }
19928 // now write the month and day
19929 auto ptr = data + year_length;
19930 FormatComponent(ptr, month);
19931 FormatComponent(ptr, day);
19932 // optionally add BC to the end of the date
19933 if (add_bc) {
19934 memcpy(ptr, " (BC)", 5); // NOLINT
19935 }
19936 }

◆ Format() [2/2]

static void duckdb::DateToStringCast::Format ( char data,
int32_t  date[],
idx_t  year_length,
bool  add_bc 
)
inlinestatic
19938 {
19939 Format(data, date[0], date[1], date[2], year_length, add_bc);
19940 }

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