DateTimeData Manual

内容表

关于

A DateTimeData stores a date and a time. Using a DateTime structure, it stores the year, month, day, hour, minute and second.
For more specific operation related to time, see TimeValue Manual .

Access

使用 C4DAtom::GetParameter() to retrieve the data of a parameter and cast it to DateTimeData .

// This example retrieves the actual DateTime from a sky object.
GeData data; // Retrieves the parameter from the physical sky object. Bool success = mySkyObject->GetParameter( SKY_DATE_TIME , data, DESCFLAGS_GET::NONE );

// Checks if we retrieved the data and its type. if (!success || data. GetType () != DATETIME_DATA ) return maxon::UnexpectedError( MAXON_SOURCE_LOCATION );

// Retrieves the data from data container. DateTimeData * dateTimeData = static_cast< DateTimeData * > (data. GetCustomDataType ( DATETIME_DATA ));

if (dateTimeData == nullptr ) return maxon::UnexpectedError( MAXON_SOURCE_LOCATION );

使用 C4DAtom::SetParameter() to set the DateTimeData of your parameter.
The custom data type must be specified in the GeData constructor.

// Sets the physical sky object parameter with the new data. Bool success = mySkyObject->SetParameter( DescID ( SKY_DATE_TIME ), GeData ( DATETIME_DATA , dateTimeData), DESCFLAGS_SET::NONE ); if (!success) return maxon::UnknownError( MAXON_SOURCE_LOCATION );

Add a parameter in a description

A parameter can be added to a description with the function ::GetDDescription(). To attach a custom GUI to that parameter define DESC_CUSTOMGUI settings and call SetParameter(). See DateTimeControl Manual .

// This example shows how to implement a BaseTimeData parameter with a custom GUI. DescID cid = DescLevel (dateTimeID, DATETIME_DATA , 0); if (!singleid || cid. IsPartOf (*singleid, nullptr )) { BaseContainer settings = GetCustomDataTypeDefault ( DATETIME_DATA ); // Sets the name 设置。 SetString ( DESC_NAME , "Date Time" _s); 设置。 SetString ( DESC_SHORT_NAME , "Date Time" _s);

// Sets the custom GUI displaying that parameter. // GetCustomDataTypeDefault sets it to DATETIME_GUI by default. 设置。 SetInt32 ( DESC_CUSTOMGUI , DATETIME_GUI );

// Activates the now button 设置。 SetBool ( DATETIME_NOW_BUTTON , true );

// Activates the clock 设置。 SetBool ( DATETIME_TIME_CONTROL , true );

// Activates the calendar 设置。 SetBool ( DATETIME_DATE_CONTROL , true );

// The maximized GUI is shown by default. 设置。 SetBool ( DESC_GUIOPEN , true );

// Inserts the parameter in the description if (!description-> SetParameter (cid, settings, ID_OBJECTPROPERTIES )) return false ; }

DateTime Structure

Represents a date and a time.

Inside DateTimeData , DataTime is only accessible via those functions:

// This example shows how to set and get a DateTimeData.

// Creates a DateTime for Alan Turing's birthday. DateTime timeSet(1912, 6, 23, 23, 59, 59);

// Allocates a new DateTimeData. AutoAlloc<DateTimeData> dateTimeData; if (dateTimeData == nullptr ) return maxon::OutOfMemoryError( MAXON_SOURCE_LOCATION );

// Sets the DateTimeData to the new time/date. dateTimeData-> SetDateTime (timeSet);

// Retrieves the DateTime From DateTimeData. const DateTime timeGet = dateTimeData-> GetDateTime ();

DateTime Properties

The Structure of the DateTime is composed by those properties.

Constructors

A DateTime can be created passing some argument in the constructor as follow:

DateTime (Int32 t_year, Int32 t_month, Int32 t_day, Int32 t_hour, Int32 t_minute, Int32 t_second);

// Allocates a new DateTimeData using AutoAlloc. AutoAlloc<DateTimeData> dateTimeData; if (dateTimeData == nullptr ) return maxon::OutOfMemoryError( MAXON_SOURCE_LOCATION );

// Released the pointer if needed. DateTimeData * anotherPointer = dateTimeData. 发行 ();

// Another way to Alloc a DateTimeData using GeData. GeData data = GeData ( DATETIME_DATA , DEFAULTVALUE ); DateTimeData * value = static_cast< DateTimeData * > (data. GetCustomDataType ( DATETIME_DATA )); if (value == nullptr ) return maxon::OutOfMemoryError( MAXON_SOURCE_LOCATION );

// Creates a Date time. DateTime dateTime(1912, 6, 23, 23, 59, 59);

// Sets the DateTimeData. value-> SetDateTime (dateTime);

// Frees the pointer as we took ownership. DateTimeData::Free (anotherPointer);

Functionality

There are several functions to manipulate dates and times.

String

DateTime can be converted as a String with:

Julian format

Transforms DateTime to Julian date in both directions.

Current DateTime

Retrieves the current date and time.

Convert DateTime

Converts date and time to GMT or local date and time.

Day of week

Gets the day of the week.

Validate

Tries to correct invalid data.

比较

There are several operators that can be used to compare DateTime .

延伸阅读

DateTimeData::SetDateTime
void SetDateTime(const DateTime &d, Bool bSetDate=true, Bool bSetTime=true)
SKY_DATE_TIME
@ SKY_DATE_TIME
定义: oskyshader.h:54
GetCustomDataTypeDefault
BaseContainer GetCustomDataTypeDefault(Int32 type)
ID_OBJECTPROPERTIES
@ ID_OBJECTPROPERTIES
定义: obase.h:53
GetDayOfWeek
DAYOFWEEK GetDayOfWeek(Int32 lYear, Int32 lMonth, Int32 lDay)
DescID
定义: lib_description.h:327
GeData::GetType
Int32 GetType(void) const
定义: c4d_gedata.h:407
BaseContainer::SetInt32
void SetInt32(Int32 id, Int32 l)
定义: c4d_basecontainer.h:505
DateTimeData::Free
static void Free(DateTimeData *&pData)
BaseContainer::SetString
void SetString(Int32 id, const maxon::String &s)
定义: c4d_basecontainer.h:569
FromJulianDay
DateTime FromJulianDay(Float64 j)
ValidateTime
void ValidateTime(Int32 &hour, Int32 &minute, Int32 &second)
maxon::String
定义: string.h:1197
DescID::IsPartOf
Bool IsPartOf(const DescID &cmp, Int32 *pos) const
GetDateTimeNow
void GetDateTimeNow(DateTime &t)
DATETIME_DATE_CONTROL
#define DATETIME_DATE_CONTROL
Bool true, if it is a calendar.
定义: customgui_datetime.h:29
DESC_GUIOPEN
@ DESC_GUIOPEN
Bool true if the maximized GUI is shown by default.
定义: lib_description.h:130
GetMonthName
String GetMonthName(Int month)
MAXON_SOURCE_LOCATION
#define MAXON_SOURCE_LOCATION
定义: memoryallocationbase.h:66
CompareDateTime
Int32 CompareDateTime(const DateTime &a, const DateTime &b)
maxon::Float
Float64 Float
定义: apibase.h:193
BaseContainer::SetBool
void SetBool(Int32 id, Bool b)
定义: c4d_basecontainer.h:498
DateTimeData
定义: customgui_datetime.h:156
Description::SetParameter
Bool SetParameter(const DescID &id, const BaseContainer ¶m, const DescID &groupid)
DESCFLAGS_SET::NONE
@ NONE
None.
DiagnosticOutput
#define DiagnosticOutput(formatString,...)
定义: debugdiagnostics.h:166
FormatTime
String FormatTime(const char *pszFormat, const DateTime &t)
DATETIME_GUI
#define DATETIME_GUI
DateTime custom GUI ID.
定义: customgui_datetime.h:20
ValidateDate
void ValidateDate(Int32 &year, Int32 &month, Int32 &day)
DATETIME_TIME_CONTROL
#define DATETIME_TIME_CONTROL
Bool true, if it is a clock.
定义: customgui_datetime.h:28
DateTime
Represents a date and time.
定义: customgui_datetime.h:38
maxon::Int32
int32_t Int32
32 bit signed integer datatype.
定义: apibase.h:172
GetJulianDay
Float64 GetJulianDay(const DateTime &t)
DESC_SHORT_NAME
@ DESC_SHORT_NAME
String Short name, for attributes dialog.
定义: lib_description.h:92
DescLevel
Represents a level within a DescID.
定义: lib_description.h:286
GeData
定义: c4d_gedata.h:82
ParseTimeString
Bool ParseTimeString(String timestr, Int32 &hour, Int32 &minute, Int32 &second)
DateToString
String DateToString(const DateTime &d)
DEFAULTVALUE
@ DEFAULTVALUE
Dummy value for the default value GeData constructor.
定义: c4d_gedata.h:65
DESC_CUSTOMGUI
@ DESC_CUSTOMGUI
Int32 The ID of the GUI for this element. Either a custom ID or one of: CUSTOMGUI
定义: lib_description.h:125
DateTimeData::GetDateTime
DateTime GetDateTime() const
FormatString
#define FormatString(...)
定义: string.h:2031
AutoAlloc::Release
TYPE * Release()
定义: ge_autoptr.h:120
AutoAlloc
定义: ge_autoptr.h:36
DESCFLAGS_GET::NONE
@ NONE
None.
DATETIME_DATA
#define DATETIME_DATA
DateTime custom data ID.
定义: customgui_datetime.h:23
GeData::GetCustomDataType
CustomDataType * GetCustomDataType(Int32 datatype) const
定义: c4d_gedata.h:507
DATETIME_NOW_BUTTON
#define DATETIME_NOW_BUTTON
Bool true, to add "Now" button.
定义: customgui_datetime.h:30
DESC_NAME
@ DESC_NAME
String Name for standalone use.
定义: lib_description.h:91
TimeToString
String TimeToString(const DateTime &d, const Bool bShowSeconds=true)
Bool
maxon::Bool Bool
定义: ge_sys_math.h:53
DateTime::month
Int32 month
Month.
定义: customgui_datetime.h:63
Char
maxon::Char Char
定义: ge_sys_math.h:54
LocalToGMTime
Bool LocalToGMTime(const DateTime &tLocal, DateTime &tGMT)
BaseContainer
定义: c4d_basecontainer.h:46

Copyright  © 2014-2025 乐数软件    

工业和信息化部: 粤ICP备14079481号-1