String Value_datetime_imp::get_String( tslen inLimit ) const { String str; if( inLimit != 0 ) { UChar* p = str.getBuffer(kDateTimeStrMaxLength + 1); const DTFormat* pDTFormat = get_DTFormat(); Convert_datetime_str_fast( (DateTimeEncoded&)mValue, pDTFormat->mDateFormat, pDTFormat->mDateSep, pDTFormat->mTimeSep, p ); if( ((DateTimeEncoded&)mValue).encoded < 0 ) str.releaseBuffer(kDateTimeStrMaxLength); // 24 symbols for negative dates else str.releaseBuffer(kDateTimeStrMaxLength - 1); // 23 symbols for positive dates // not -1 and less than maxLen if( inLimit > 0 && vuint32(inLimit) < kDateTimeStrMaxLength ) { str.truncate( inLimit ); } } return str; }
char* Value_time_imp::get_String( char* outString, tslen inBufferChars ) const { // The size of input buffer (inBufferChars) cannot be -1 ! // Because this is unsafe then to write to the memory // location pointed by outString - because we don't know the size ! if( outString == nullptr || inBufferChars <= 0 ) return nullptr; char* pEnd = nullptr; if( inBufferChars < tslen(kTimeStrMaxLength) ) { String res( get_String( inBufferChars ) ); tslen len = res.length(); memcpy( outString, res.getBufferA(), len ); *(outString + len) = 0; pEnd = outString + len; } else { const DTFormat* pDTFormat = get_DTFormat(); Convert_time_str_aa_fast( (TimeEncoded&)mValue, static_cast<char>(pDTFormat->mTimeSep), outString ); pEnd = outString + kTimeStrMaxLength; } return pEnd; }
UChar* Value_date_imp::get_String( UChar* outString, tslen inBufferChars ) const { // The size of input buffer (inBufferChars) cannot be -1 ! // Because this is unsafe then to write to the memory // location pointed by outString - because we don't know the size ! if( outString == nullptr || inBufferChars <= 0 ) return nullptr; UChar* pEnd = nullptr; if( inBufferChars < tslen(kDateStrMaxLength) ) { String res( get_String( inBufferChars ) ); tslen len = res.length(); memcpy( outString, res.begin(), len * sizeof(UChar) ); *(outString + len) = 0; pEnd = outString + len; } else { const DTFormat* pDTFormat = get_DTFormat(); Convert_date_str_fast( (DateEncoded&)mValue, pDTFormat->mDateFormat, pDTFormat->mDateSep, outString ); pEnd = ( ((DateEncoded&)mValue).encoded < 0 ) ? outString + kDateStrMaxLength : outString + kDateStrMaxLength - 1; } return pEnd; }
void Value_datetime_imp::put_Year( vint32 inYear ) { const DTFormat* pDTFormat = get_DTFormat(); // Year correction pDTFormat->AutoCentury( inYear ); ((DateTimeEncoded&)mValue).decoded.date.decoded.y = inYear; put_IsNull( false ); }
void Value_time_imp::put_String( const char* inStart, const char* inEnd ) { argused1( inEnd ); const DTFormat* pDTFormat = get_DTFormat(); Convert_str_time_aa_aux( inStart, pDTFormat, (TimeEncoded&)mValue ); put_IsNull( false ); }
void Value_datetime_imp::put_String( const UChar* inStart, const UChar* inEnd ) { argused1( inEnd ); const DTFormat* pDTFormat = get_DTFormat(); Convert_str_datetime_uu_aux( inStart, inEnd, pDTFormat, (DateTimeEncoded&) mValue ); put_IsNull( false ); }
void Value_datetime_imp::put_Date( vint32 inYear, vuint16 inMonth, vuint16 inDay ) { DateEncoded& de = ((DateTimeEncoded&)mValue).decoded.date; const DTFormat* pDTFormat = get_DTFormat(); // Year correction pDTFormat->AutoCentury( inYear ); de.decoded.y = inYear; de.decoded.m = inMonth; de.decoded.d = inDay; put_IsNull( false ); }
String Value_time_imp::get_String( tslen inLimit ) const { String str; if( inLimit != 0 ) { UChar* p = str.getBuffer(kTimeStrMaxLength + 1); const DTFormat* pDTFormat = get_DTFormat(); Convert_time_str_uu_fast( (TimeEncoded&)mValue, pDTFormat->mTimeSep, p ); str.releaseBuffer(kTimeStrMaxLength); // not -1 and less than maxLen if( inLimit > 0 && vuint32(inLimit) < kTimeStrMaxLength ) { str.truncate( inLimit ); } } return str; }