MFC Grid manual

CInt64DateFormat Class Reference

This class formats time represented by 64-bit value that is the number of 100-nanosecond intervals since January 1, 1601. More...

#include <Dapfor/Common/Int64DateFormat.h>

Inheritance diagram for CInt64DateFormat:

CFormat

List of all members.


Public Types

enum  Style {
  year = 0x1, short_year = 0x2, month = 0x4, day = 0x8,
  hour = 0x10, minute = 0x20, second = 0x40, millisec = 0x80,
  date = day | month | year, short_date = day | month | short_year, time = hour | minute | second, mstime = time | millisec,
  datetime = date | time, datemstime = date | mstime, short_datetime = short_date | time, short_datemstime = short_date | mstime
}
 Data or time types. More...

Public Member Functions

 CInt64DateFormat (unsigned long nStyle)
 Constructor.
 CInt64DateFormat (const CInt64DateFormat &)
 Copy constructor.
 ~CInt64DateFormat ()
 Destructor.
virtual TString FormatStl (int64 val, const CDataObject *pDO) const
 The function converts non-formatted value of __int64 type to the string which presents the formatted date.
virtual bool ParseStl (const TString &, int64 &val, const CDataObject *pDO) const
 The function converts the string which presents the formatted date to the non-formatted value of __int64 type.
virtual CString FormatMfc (int64 val, const CDataObject *pDO) const
 The function converts non-formatted value of __int64 type to the formatted MFC string.
virtual bool ParseMfc (const CString &str, int64 &val, const CDataObject *pDO) const
 The function converts the formatted MFC string to the non-formatted __int64-type value.
virtual CFormatClone () const
 Creates a deep copy of a format.
virtual bool IsDate () const
 Indicates whether the format presents a date.
virtual unsigned long GetStyle () const
 Gets the format style that is a combination of CInt64DateFormat::Style enum.
virtual void Serialize (CSerializer &serializer)
 Serializes a format.

Static Public Member Functions

static int64 Now ()
 Gets the local time that equals the number of 100-nanosecond intervals since January 1, 1601.
static int64 UtcNow ()
static int64 FileTimeToInt64 (FILETIME ft)
static FILETIME Int64ToFileTime (int64 ft)
static int GetSerializeVertion ()
 Serialization version.
static TString FormatStl (int64 val, const CDataObject *pDO, unsigned long style, CPreferences::DateType dateType)
 A helper-function, which transforms unformatted value of __int64 type into the formatted string, depending on the format style and the date type.
static bool ParseStl (const TString &text, int64 &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 __int64 type, depending on the format style and the date type.

Detailed Description

This class formats time represented by 64-bit value that is the number of 100-nanosecond intervals since January 1, 1601.

To get current time, use the static function CInt64DateFormat::Now()

See also:
FILETIME structure in MSDN.
 Format examples:

 CPreferences::SetDateFormat(CPreferences::DayMonthYear);

 1. CInt64DateFormat(CInt64DateFormat::date).FormatStl(CInt64DateFormat::Now(), 0);
 2. CInt64DateFormat(CInt64DateFormat::short_date).FormatStl(CInt64DateFormat::Now(), 0);
 3. CInt64DateFormat(CInt64DateFormat::time).FormatStl(CInt64DateFormat::Now(), 0);
 4. CInt64DateFormat(CInt64DateFormat::short_datemstime).FormatStl(CInt64DateFormat::Now(), 0);

 CPreferences::SetDateFormat(CPreferences::MonthDayYear);

 5. CInt64DateFormat(CInt64DateFormat::date).FormatStl(CInt64DateFormat::Now(), 0);
 6. CInt64DateFormat(CInt64DateFormat::short_date).FormatStl(CInt64DateFormat::Now(), 0);
 7. CInt64DateFormat(CInt64DateFormat::time).FormatStl(CInt64DateFormat::Now(), 0);
 8. CInt64DateFormat(CInt64DateFormat::short_datemstime).FormatStl(CInt64DateFormat::Now(), 0);

 CPreferences::SetDateFormat(CPreferences::MonthDayYear);
 CPreferences::SetDateSeparator(_T("-"));

 9.  CInt64DateFormat(CInt64DateFormat::date).FormatStl(CInt64DateFormat::Now(), 0);
 10. CInt64DateFormat(CInt64DateFormat::short_date).FormatStl(CInt64DateFormat::Now(), 0);
 11. CInt64DateFormat(CInt64DateFormat::time).FormatStl(CInt64DateFormat::Now(), 0);
 12. CInt64DateFormat(CInt64DateFormat::short_datemstime).FormatStl(CInt64DateFormat::Now(), 0);


 Output strings:
 1. 16/06/2007
 2. 16/06/07
 3. 12:39:10
 4. 16/06/07 12:39:10.875

 5. 06/16/2007
 6. 06/16/07
 7. 12:39:10
 8. 06/16/07 12:39:10.875

 9.  2007-06-16
 10. 07-06-16
 11. 12:39:10
 12. 07-06-16 12:39:10.875

Member Enumeration Documentation

enum Style

Data or time types.

Enumerator:
year  yyyy
short_year  yy
month  mm 1..12
day  dd 1..31
hour  hh 0..23
minute  mm 0..59
second  ss 0..59
millisec  xxx 0..999
date  dd/mm/yyyy
short_date  dd/mm/yy
time  hh:mm:ss
mstime  hh:mm:ss.xxx
datetime  dd/mm/yyyy hh:mm:ss
datemstime  dd/mm/yyyy hh:mm:ss.xxx
short_datetime  dd/mm/yy hh:mm:ss
short_datemstime  dd/mm/yy hh:mm:ss.xxx


Constructor & Destructor Documentation

CInt64DateFormat ( unsigned long  dateType  ) 

Constructor.

Parameters:
[in] dateType Date style. Combination of CInt64DateFormat::Style enum

CInt64DateFormat ( const CInt64DateFormat format  ) 

Copy constructor.

Parameters:
[in] format Format to be copied


Member Function Documentation

TString FormatStl ( int64  val,
const CDataObject pDO 
) const [virtual]

The function converts non-formatted value of __int64 type to the string which presents the formatted date.

Parameters:
[in] val Value of __int64 type to be formatted.
[in] pDO Pointer to CDataObject. This parameter is optional and may be zero.
Returns:
Formatted string.

Reimplemented from CFormat.

bool ParseStl ( const TString &  str,
int64 &  val,
const CDataObject pDO 
) const [virtual]

The function converts the string which presents the formatted date to the non-formatted value of __int64 type.

Parameters:
[in] str Formatted date.
[in,out] val Value of __int64 type that accepts the result of conversion.
[in] pDO Pointer to CDataObject. This parameter is optional and may be zero.
Returns:
True, if the string has been successfully parsed. Otherwise false.

Reimplemented from CFormat.

CString FormatMfc ( int64  val,
const CDataObject pDO 
) const [virtual]

The function converts non-formatted value of __int64 type to the formatted MFC string.

Parameters:
[in] val Non-formatted MFC string to be formatted.
[in] pDO Pointer to CDataObject. This parameter is optional and may be zero.
Returns:
Formatted string that is a result of conversion.

Reimplemented from CFormat.

bool ParseMfc ( const CString &  str,
int64 &  val,
const CDataObject pDO 
) const [virtual]

The function converts the formatted MFC string to the non-formatted __int64-type value.

Parameters:
[in] str MFC string to be formatted.
[in,out] val A value of the __int64 type that is a result of the parsing.
[in] pDO Pointer to CDataObject. This parameter is optional and may be zero.
Returns:
True, if the string has been successfully parsed. Otherwise false.

Reimplemented from CFormat.

CFormat * Clone (  )  const [virtual]

Creates a deep copy of a format.

Returns:
Deep copy of a format object.

Implements CFormat.

bool IsDate (  )  const [virtual]

Indicates whether the format presents a date.

Returns:
Always true;

Reimplemented from CFormat.

unsigned long GetStyle (  )  const [virtual]

Gets the format style that is a combination of CInt64DateFormat::Style enum.

Returns:
Combination of CInt64DateFormat::Style enum

int64 Now (  )  [static]

Gets the local time that equals the number of 100-nanosecond intervals since January 1, 1601.

Returns:
Local time, represented by 64-bit value.

int64 UtcNow (  )  [static]

Returns:
This function retrieves the current system date and time. The system time is expressed in UTC, represented by 64-bit value.

int64 FileTimeToInt64 ( FILETIME  ft  )  [static]

Parameters:
[in] ft Time, represented by the FILETIME structure
Returns:
Time, represented by the 64-bit value. It has the same format that the FILETIME structure.

FILETIME Int64ToFileTime ( int64  ft  )  [static]

Parameters:
[in] ft Time, represented by the 64-bit value. It has the same format that the FILETIME structure.
Returns:
Time, represented by the FILETIME structure

void Serialize ( CSerializer serializer  )  [virtual]

Serializes a format.

Parameters:
[in] serializer Object, into which a format object is serialized.

Reimplemented from CFormat.

TString FormatStl ( int64  val,
const CDataObject pDO,
unsigned long  style,
CPreferences::DateType  dateType 
) [static]

A helper-function, which transforms unformatted value of __int64 type into the formatted string, depending on the format style and the date type.

Parameters:
[in] val Unformatted value
[in] pDO Pointer to the data object
[in] style Format style. Combination of CInt64DateFormat::Style enumeration
[in] dateType Date type.
Returns:
Formatted string.

bool ParseStl ( const TString &  str,
int64 &  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 __int64 type, depending on the format style and the date type.

Parameters:
[in] str Date string
[in,out] val Value to be filled.
[in] pDO Pointer to the data object
[in] style Format style. Combination of CInt64DateFormat::Style enumeration
[in] dateType Date type.
Returns:
True if the string has been succsessfully parsed. Otherwise false.