// get the value of a property
qbool oDateTime::getProperty(qlong pPropID,EXTfldval &pGetValue,EXTCompInfo* pECI) {
	// most anum properties are managed by Omnis but some we need to do ourselves...
		
	switch (pPropID) {
		case oDT_localtime: {
			struct tm *		timestruct = localtime(&mTimestamp);
			datestamptype	omnisstamp;
			
			TimeStampToOmnis(*timestruct,omnisstamp);
			
			pGetValue.setDate(omnisstamp, dpFdtimeC);
            return true;
		}; break;
		case oDT_utctime: {
			struct tm *		timestruct = gmtime(&mTimestamp);
			datestamptype	omnisstamp;
			
			TimeStampToOmnis(*timestruct,omnisstamp);
			
			pGetValue.setDate(omnisstamp, dpFdtimeC);
            return true;
		}; break;
		default:
			return oBaseNVComponent::getProperty(pPropID, pGetValue, pECI);
				
			break;
	};
};	
// Get an EXTfldval for a C time
void OmnisTools::getEXTFldValFromTime(EXTfldval& fVal, struct tm* cTime) {
    
    datestamptype convDate;
    
    // Date
    convDate.mYear = static_cast<qshort>(cTime->tm_year+1900);  // Years since 1900
    convDate.mMonth = static_cast<char>(cTime->tm_mon+1); // 0 = January, 11 = December
    convDate.mDay = static_cast<char>(cTime ->tm_mday);
    convDate.mDateOk = static_cast<char>(qtrue);
    
    // Time
    convDate.mHour = static_cast<char>(cTime->tm_hour);
    convDate.mMin = static_cast<char>(cTime->tm_min);
    convDate.mSec = static_cast<char>(cTime->tm_sec);
    convDate.mTimeOk = static_cast<char>(qtrue);
    
    convDate.mHunOk = static_cast<char>(qfalse);
    
    fVal.setDate(convDate, dpFdtimeC);
}
// This method sets up the passed in EXTfldval with a date representing the ISO8601 Date passed in
void OmnisTools::getEXTfldvalFromISO8601DateString(EXTfldval& fVal, std::string dateString) {

    boost::smatch theMatch;
    datestamptype theDate;
    
    if( boost::regex_match(dateString,theMatch,datetimeCheck) ) { 
        // Match date/time
        fVal.setEmpty(fftDate, dpFdtimeC);
        fVal.getDate(theDate);
        
        theDate.mDateOk = qtrue;
        theDate.mYear = lexical_cast<qshort>(theMatch[1]);  // First match is year
        theDate.mMonth = (char) lexical_cast<qshort>(theMatch[2]);  // Second match is month
        theDate.mDay = (char) lexical_cast<qshort>(theMatch[3]);  // Third match is day
        
        theDate.mTimeOk = qtrue;
        theDate.mHour = (char) lexical_cast<qshort>(theMatch[4]);  // Fourth match is hour
        theDate.mMin = (char) lexical_cast<qshort>(theMatch[5]);  // Fifth match is minute
        
        theDate.mSecOk = qfalse;
        theDate.mHunOk = qfalse;
        
        // Optional matches
        if (theMatch[6].matched && theMatch[6].length() > 0) {
            // Appears to have the seconds portion
            theDate.mSecOk = qtrue;
            theDate.mSec = lexical_cast<int>(theMatch[6]);  // Sixth match is seconds
        }
        
        fVal.setDate(theDate, dpFdtimeC);
        
    } else if ( boost::regex_match(dateString,theMatch,dateCheck) ) {
        // Match date
        fVal.setEmpty(fftDate, dpFdate2000);
        fVal.getDate(theDate);
        
        theDate.mDateOk = qtrue;
        theDate.mYear = lexical_cast<qshort>(theMatch[1]);  // First match is year
        theDate.mMonth = (char) lexical_cast<qshort>(theMatch[2]);  // Second match is month
        theDate.mDay = (char) lexical_cast<qshort>(theMatch[3]);  // Third match is day
        
        theDate.mTimeOk = qfalse;
        theDate.mSecOk = qfalse;
        theDate.mHunOk = qfalse;
        
        fVal.setDate(theDate, dpFdate2000);
        
    } else if ( boost::regex_match(dateString,theMatch,timeCheck) ) {
        // Match time
        fVal.setEmpty(fftDate, dpFtime);
        fVal.getDate(theDate);
        
        theDate.mDateOk = qfalse;
        theDate.mTimeOk = qtrue;
        theDate.mHour = (char) lexical_cast<qshort>(theMatch[1]);  // First match is hour
        theDate.mMin = (char) lexical_cast<qshort>(theMatch[2]);  // Second match is minute
        
        theDate.mSecOk = qfalse;
        theDate.mHunOk = qfalse;
        
        // Optional matches
        if (theMatch[3].matched && theMatch[3].length() > 0) {
            // Appears to have the seconds portion
            theDate.mSecOk = qtrue;
            theDate.mSec = (char) lexical_cast<qshort>(theMatch[3]);  // Third match is seconds
        }
        
        fVal.setDate(theDate);
    }
}