#include <lkdatetimereader.h>
Public Types | |
enum | DatePartOrder { AnyPreferDMY = 1, AnyPreferMDY, DMY, MDY, YMD } |
What order will the date parts be in? More... | |
enum | DateTimeOrder { AnyPreferDT = 1, AnyPreferTD, DT, TD } |
What order will the date and time be in? More... | |
Static Public Methods | |
bool | ReadDate (const LookString &theString, LookDate &theDate, DatePartOrder partOrder=AnyPreferDMY) |
Try to parse a date. More... | |
bool | ReadTime (const LookString &theString, LookTime &theTime) |
Try to parse a time. More... | |
bool | ReadDateTime (const LookString &theString, LookDateTime &theDateTime, DateTimeOrder dtOrder=AnyPreferDT, DatePartOrder partOrder=AnyPreferDMY) |
Try to parse a date/time. More... | |
Static Protected Methods | |
bool | FindYearPart (const LookString &theString, bool &yearIsAtBegin) |
void | SplitToParts (LookStringList &theParts, const LookString &theString) |
LookString | GetAlphaOnly (LookString theString) |
bool | FindMonthString (LookStringList &theParts, int &monthIndex) |
bool | IsNumeric (const LookString &theString) |
void | CombineSplitStrings (const LookStringList &theParts, long theSplitPos, LookString &beforeString, LookString &afterString) |
void | GuessDTOrder (const LookString &theString, DateTimeOrder &dtOrder) |
void | SplitToPartsFindSeps (LookStringList &theParts, LongValList &theDateSepPositions, LongValList &theTimeSepPositions, const LookString &theString) |
void | CheckForSepsAndAddIfValid (LookString theString, LookStringList &theParts, LongValList &theDateSepPositions, LongValList &theTimeSepPositions) |
This tries quite hard to convert a string (eg user input) into a date and time.
It can cope with spelled months of the form January and Jan, and also roman numerals (eg "IX"). This is of course case-insensitive.
You can specify the order the date parts should be in. Eg "20012012" could be 20 Dec 2001 or 20 Jan 2012. If you leave it to guess if will give up, but if you know the format it will use that.
Similarly you can specify the order date and time parts should be in. Eg "20-12-09 13-05-12" could be 13:05:12 on 20 December 2009 or the other way round.
Times are always Hours Minutes Seconds.
It treats any non-digit characters as spacing the date/time parts, and it will also cope with non-split strings (eg 20010531 (which will be guessed as ymd)). (however time and date must be split)
It uses the fact that some dates/times are impossible to help it tell which it actually is. Eg 05312001 is MDY
With date/time, it knows that : and . tend to seperate time parts, and / and - do dates, and uses that to help.
I have found it copes with most sensible input and quite a lot of less sensible input too. If used in a user interface it is recommended to show the results it managed to convert in a non-ambiguous form so the user can see it understood.
If it fails to convert, DbError is set appropriately.
|
What order will the date parts be in?
|
|
What order will the date and time be in?
|
|
Try to parse a date.
|
|
Try to parse a date/time.
|
|
Try to parse a time.
|