00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 #ifndef LIBLOOKDB_LKDATETIMEREADER_H
00019 #define LIBLOOKDB_LKDATETIMEREADER_H
00020 
00021 
00022 
00023 #include "lookdbutils.h"
00024 #include "lkstring.h"
00025 #include "lkdatetime.h"
00026 #include "lookstringlist.h"
00027 #include "looklonglist.h"
00028 
00029 namespace look {
00030 
00032 
00066 class LOOKDBUTILITIES_DLL LookDateTimeReader
00067 {
00068 public:
00069 
00071         enum DatePartOrder
00072         {
00073                 AnyPreferDMY = 1, 
00074                 AnyPreferMDY,     
00075                 DMY,              
00076                 MDY,              
00077                 YMD               
00078         };
00079 
00081         enum DateTimeOrder
00082         {
00083                 AnyPreferDT = 1, 
00084                 AnyPreferTD,     
00085                 DT,              
00086                 TD               
00087         };
00088 
00089         static bool ReadDate( const LookString& theString,
00090                 LookDate& theDate, DatePartOrder partOrder = AnyPreferDMY );
00091         static bool ReadTime( const LookString& theString,
00092                 LookTime& theTime );
00093         static bool ReadDateTime( const LookString& theString,
00094                 LookDateTime& theDateTime, DateTimeOrder dtOrder = AnyPreferDT,
00095                 DatePartOrder partOrder = AnyPreferDMY );
00096 
00097 protected:
00098 
00099         static bool FindYearPart( const LookString& theString,
00100                 bool& yearIsAtBegin );
00101 
00102         static void SplitToParts( LookStringList& theParts,
00103                 const LookString& theString );
00104 
00105         static LookString GetAlphaOnly( LookString theString );
00106 
00107         static bool FindMonthString( LookStringList& theParts,
00108                 int& monthIndex );
00109 
00110         static bool IsNumeric( const LookString& theString );
00111 
00112         static void CombineSplitStrings( 
00113                 const LookStringList& theParts, long theSplitPos,
00114                 LookString& beforeString, LookString& afterString );
00115 
00116         static void GuessDTOrder( const LookString& theString,
00117                 DateTimeOrder& dtOrder );
00118 
00119         static void SplitToPartsFindSeps( LookStringList& theParts,
00120                 LongValList& theDateSepPositions,
00121                 LongValList& theTimeSepPositions,
00122                 const LookString& theString );
00123 
00124         static void CheckForSepsAndAddIfValid( 
00125                 LookString theString,
00126                 LookStringList& theParts,
00127                 LongValList& theDateSepPositions,
00128                 LongValList& theTimeSepPositions );
00129 };
00130 
00131 
00132 } 
00133 #endif