DateTimeParser Class Reference

#include <lib_datetimeparser.h>

Detailed Description

Class to parse and create date time strings.

Note
Has to be created with Alloc() and destroyed with Free(). Use AutoAlloc to automate the allocation and destruction based on scope.

Example:

GePrint(sDateFormat + " " + sTimeFormat);
GePrint(sDate + " " + sTime);

Private Member Functions

 DateTimeParser ()
 
 ~DateTimeParser ()
 

Alloc/Free

static DateTimeParserAlloc (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)
 

Constructor & Destructor Documentation

◆ DateTimeParser()

DateTimeParser ( )
private

◆ ~DateTimeParser()

~DateTimeParser ( )
private

Member Function Documentation

◆ Alloc()

static DateTimeParser* Alloc ( void  )
static

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

Returns
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(). Use AutoAlloc to automate the allocation and destruction based on scope.

Parameters
[in,out]dtpThe 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.

Parameters
[in]strThe string to parse.
[in]resultAssigned the parsed result.
[in]modeThe date time mode: DATETIMEPARSERMODE
Returns
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".

Parameters
[in]dtThe date time to create the string from.
[in]modeThe date time mode: DATETIMEPARSERMODE
Returns
The date time string.

◆ SetFormatString()

void SetFormatString ( const String sFormat,
DATETIMEPARSERMODE  mode 
)

Sets the formating of the time string.

Parameters
[in]sFormatThe formating string, e.g. "HH:MM:SS" for time and "YYYY-MM-DD" for the date.
[in]modeThe date time mode: DATETIMEPARSERMODE

◆ GetFormatString()

String GetFormatString ( DATETIMEPARSERMODE  mode)

Retrieves the current date time formating string.

Parameters
[in]modeThe date time mode: DATETIMEPARSERMODE
Returns
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
Definition: c4d_string.h:38
DateTime
Represents a date and time.
Definition: customgui_datetime.h:38
DATETIMEPARSERMODE::DATE
@ DATE
Date.
DateTimeParser::ParseString
Bool ParseString(const String &str, DateTime &result, DATETIMEPARSERMODE mode)
AutoAlloc
Definition: ge_autoptr.h:36