DateTimeParser Class Reference Library » DateTime Parser

#include <lib_datetimeparser.h>

详细描述

Class to parse and create date time strings.

注意
Has to be created with Alloc() and destroyed with Free() 。使用 AutoAlloc to automate the allocation and destruction based on scope.

范例:

AutoAlloc<DateTimeParser> dtp;
dtp-> SetFormatString ( "YYYY-MM-DD" , DATETIMEPARSERMODE::DATE ); dtp-> SetFormatString ( "HH:MM:SS" , DATETIMEPARSERMODE::TIME ); String sDateFormat = dtp-> GetFormatString ( DATETIMEPARSERMODE::DATE ); String sTimeFormat = dtp-> GetFormatString ( DATETIMEPARSERMODE::TIME ); GePrint (sDateFormat + " " + sTimeFormat); DateTime dt; dtp-> ParseString ( "110325" , dt, DATETIMEPARSERMODE::DATE ); dtp-> ParseString ( "54321" , dt, DATETIMEPARSERMODE::TIME ); String sDate = dtp-> MakeString (dt, DATETIMEPARSERMODE::DATE ); String sTime = dtp-> MakeString (dt, DATETIMEPARSERMODE::TIME ); GePrint (sDate + " " + sTime);

私有成员函数

  DateTimeParser ()
  ~DateTimeParser ()

Alloc/Free

static DateTimeParser Alloc (void)
static void  Free ( DateTimeParser *&dtp)

Parse/Make String

Bool   ParseString (const String &str, DateTime &result, DATETIMEPARSERMODE mode)
String   MakeString (const DateTime &dt, DATETIMEPARSERMODE mode)

Format String

void  SetFormatString (const String &sFormat, DATETIMEPARSERMODE mode)
String   GetFormatString ( DATETIMEPARSERMODE mode)

构造函数 & 析构函数文档编制

◆  DateTimeParser()

DateTimeParser () private

◆  ~DateTimeParser()

~ DateTimeParser () private

成员函数文档编制

◆  Alloc()

static DateTimeParser * Alloc ( void  )
static

Allocates a date time parser. Destroy the allocated date time parser with Free() 。使用 AutoAlloc to automate the allocation and destruction based on scope.

返回
The allocated date time parser, or nullptr if the allocation failed.

◆  Free()

static void Free ( DateTimeParser *&  dtp )
static

Destructs date time parsers allocated with Alloc() 。使用 AutoAlloc to automate the allocation and destruction based on scope.

参数
[in,out] dtp The date time parser to destruct. If the pointer is nullptr nothing happens. The pointer is assigned nullptr afterwards.

◆  ParseString()

Bool ParseString ( const String str ,
DateTime result ,
DATETIMEPARSERMODE   mode  
)

Parses a date time string.

参数
[in] str The string to parse.
[in] result Assigned the parsed result.
[in] mode The date time mode: DATETIMEPARSERMODE
返回
true if successful, otherwise false .

◆  MakeString()

String MakeString ( const DateTime dt ,
DATETIMEPARSERMODE   mode  
)

Creates a date time string, e.g. "12:24:05" or "2011-08-23" .

参数
[in] dt The date time to create the string from.
[in] mode The date time mode: DATETIMEPARSERMODE
返回
The date time string.

◆  SetFormatString()

void SetFormatString ( const String sFormat ,
DATETIMEPARSERMODE   mode  
)

Sets the formating of the time string.

参数
[in] sFormat The formating string, e.g. "HH:MM:SS" for time and "YYYY-MM-DD" for the date.
[in] mode The date time mode: DATETIMEPARSERMODE

◆  GetFormatString()

String GetFormatString ( DATETIMEPARSERMODE   mode )

Retrieves the current date time formating string.

参数
[in] mode The date time mode: DATETIMEPARSERMODE
返回
The formating string, e.g. "HH:MM:SS" for time and "YYYY-MM-DD" for the date.
DATETIMEPARSERMODE::TIME
@ TIME
Time.
DateTimeParser::GetFormatString
String GetFormatString(DATETIMEPARSERMODE mode)
DateTimeParser::SetFormatString
void SetFormatString(const String &sFormat, DATETIMEPARSERMODE mode)
GePrint
void GePrint(const maxon::String &str)
DateTimeParser::MakeString
String MakeString(const DateTime &dt, DATETIMEPARSERMODE mode)
String
定义: c4d_string.h:38
DateTime
Represents a date and time.
定义: customgui_datetime.h:38
DATETIMEPARSERMODE::DATE
@ DATE
Date.
DateTimeParser::ParseString
Bool ParseString(const String &str, DateTime &result, DATETIMEPARSERMODE mode)
AutoAlloc
定义: ge_autoptr.h:36