Public Types | |
enum | Style { year = 0x1, short_year = 0x2, month = 0x4, day = 0x8, hour = 0x10, minute = 0x20, second = 0x40, date = day | month | year, short_date = day | month | short_year, time = hour | minute | second, datetime = date | time, short_datetime = short_date | time } |
Format style. More... | |
Public Member Functions | |
CLongDateFormat (unsigned long nType) | |
Constructor. | |
CLongDateFormat (const CLongDateFormat &) | |
Copy constructor. | |
~CLongDateFormat () | |
Virtual destructor. | |
virtual TString | FormatStl (long val, const CDataObject *pDO) const |
The function converts a non-formatted value of long type to the string which presents the formatted date. | |
virtual bool | ParseStl (const TString &, long &val, const CDataObject *pDO) const |
The function converts the string which presents the formatted date to the non-formatted value of long type. | |
virtual CString | FormatMfc (long val, const CDataObject *pDO) const |
The function converts non-formatted value of long type to the formatted MFC string. | |
virtual bool | ParseMfc (const CString &str, long &val, const CDataObject *pDO) const |
The function converts the formatted MFC string to the non-formatted long-type value. | |
virtual CFormat * | Clone () const |
Creates a deep copy of a format. | |
virtual bool | IsDate () const |
Indicates whether a format presents a date. | |
unsigned long | GetStyle () const |
Gets a format style which is a combination of CLongDateFormat::Style enumeration. | |
virtual void | Serialize (CSerializer &serializer) |
Serializes a format. | |
Static Public Member Functions | |
static long | Now () |
Gets local time, that is a number of seconds elapsed since midnight, January 1, 1970. | |
static int | GetSerializeVertion () |
Serialization version. | |
static TString | FormatStl (long val, const CDataObject *pDO, unsigned long style, CPreferences::DateType dateType) |
A helper-function, which transforms unformatted value of long type into the formatted string, depending on a format style and a date type. | |
static bool | ParseStl (const TString &text, long &val, const CDataObject *pDO, unsigned long style, CPreferences::DateType dateType) |
A helper-function, which parses the formatted string which presents a date to the value of long type, depending on a format style and a date type. |
To get the current time, use the static function CLongDateFormat::Now()
Format examples: CPreferences::SetDateType(CPreferences::DayMonthYear); 1. CLongDateFormat(CLongDateFormat::date).FormatStl(CLongDateFormat::Now(), 0); 2. CLongDateFormat(CLongDateFormat::short_date).FormatStl(CLongDateFormat::Now(), 0); 3. CLongDateFormat(CLongDateFormat::time).FormatStl(CLongDateFormat::Now(), 0); 4. CLongDateFormat(CLongDateFormat::short_datetime).FormatStl(CLongDateFormat::Now(), 0); CPreferences::SetDateType(CPreferences::MonthDayYear); 5. CLongDateFormat(CLongDateFormat::date).FormatStl(CLongDateFormat::Now(), 0); 6. CLongDateFormat(CLongDateFormat::short_date).FormatStl(CLongDateFormat::Now(), 0); 7. CLongDateFormat(CLongDateFormat::time).FormatStl(CLongDateFormat::Now(), 0); 8. CLongDateFormat(CLongDateFormat::short_datetime).FormatStl(CLongDateFormat::Now(), 0); CPreferences::SetDateType(CPreferences::YearMonthDay); CPreferences::SetDateSeparator(_T("-")); 9. CLongDateFormat(CLongDateFormat::date).FormatStl(CLongDateFormat::Now(), 0); 10. CLongDateFormat(CLongDateFormat::short_date).FormatStl(CLongDateFormat::Now(), 0); 11. CLongDateFormat(CLongDateFormat::time).FormatStl(CLongDateFormat::Now(), 0); 12. CLongDateFormat(CLongDateFormat::short_datetime).FormatStl(CLongDateFormat::Now(), 0); Output strings: 1. 16/06/2007 2. 16/06/07 3. 13:18:58 4. 16/06/07 13:18:58 5. 06/16/2007 6. 06/16/07 7. 13:18:58 8. 06/16/07 13:18:58 9. 2007-06-16 10. 07-06-16 11. 13:18:58 12. 07-06-16 13:18:58
enum Style |
CLongDateFormat | ( | unsigned long | style | ) |
CLongDateFormat | ( | const CLongDateFormat & | format | ) |
Copy constructor.
[in] | format | Format to be copied. |
TString FormatStl | ( | long | val, | |
const CDataObject * | pDO | |||
) | const [virtual] |
The function converts a non-formatted value of long type to the string which presents the formatted date.
[in] | val | Value of long type to be formatted. |
[in] | pDO | Pointer to CDataObject. This parameter is optional and may be zero. |
Reimplemented from CFormat.
bool ParseStl | ( | const TString & | str, | |
long & | val, | |||
const CDataObject * | pDO | |||
) | const [virtual] |
The function converts the string which presents the formatted date to the non-formatted value of long type.
[in] | str | Formatted date. |
[in,out] | val | Value of long type that accepts the result of conversion. |
[in] | pDO | Pointer to CDataObject. This parameter is optional and may be zero. |
Reimplemented from CFormat.
CString FormatMfc | ( | long | val, | |
const CDataObject * | pDO | |||
) | const [virtual] |
The function converts non-formatted value of long type to the formatted MFC string.
[in] | val | Non-formatted MFC string to be formatted. |
[in] | pDO | Pointer to CDataObject. This parameter is optional and may be zero. |
Reimplemented from CFormat.
bool ParseMfc | ( | const CString & | str, | |
long & | val, | |||
const CDataObject * | pDO | |||
) | const [virtual] |
The function converts the formatted MFC string to the non-formatted long-type value.
[in] | str | MFC string to be formatted. |
[in,out] | val | A value of the long type that is a result of the parsing. |
[in] | pDO | Pointer to CDataObject. This parameter is optional and may be zero. |
Reimplemented from CFormat.
CFormat * Clone | ( | ) | const [virtual] |
long Now | ( | ) | [static] |
Gets local time, that is a number of seconds elapsed since midnight, January 1, 1970.
bool IsDate | ( | ) | const [virtual] |
unsigned long GetStyle | ( | ) | const |
Gets a format style which is a combination of CLongDateFormat::Style enumeration.
void Serialize | ( | CSerializer & | serializer | ) | [virtual] |
Serializes a format.
[in] | serializer | Object, into which a format object is serialized. |
Reimplemented from CFormat.
TString FormatStl | ( | long | val, | |
const CDataObject * | pDO, | |||
unsigned long | style, | |||
CPreferences::DateType | dateType | |||
) | [static] |
A helper-function, which transforms unformatted value of long type into the formatted string, depending on a format style and a date type.
[in] | val | Unformatted value |
[in] | pDO | Pointer to a data object |
[in] | style | Format style. Combination of CLongDateFormat::Style enumeration |
[in] | dateType | Date type. |
bool ParseStl | ( | const TString & | str, | |
long & | val, | |||
const CDataObject * | pDO, | |||
unsigned long | style, | |||
CPreferences::DateType | dateType | |||
) | [static] |
A helper-function, which parses the formatted string which presents a date to the value of long type, depending on a format style and a date type.
[in] | str | Date string |
[in,out] | val | Value to be filled. |
[in] | pDO | Pointer to a data object |
[in] | style | Format style. Combination of CLongDateFormat::Style enumeration |
[in] | dateType | Date type. |
Copyright Dapfor 2007-2009 | Generated on Wed Jul 7 03:24:43 2010 for MFCGrid by 1.5.5 |