About
maxon::LocalDateTime is a MAXON API class used to create an object capable of representing local time and date in a convenient and effective manner to reduce the effort of handling localized time and date representation. It's indeed recommended to use the maxon::UniversalDateTime whenever possible to store normalized time and date values and convert them the localized as late as possible.
- Warning
- maxon::LocalDateTime exposes all the available members as public leaving the developer the option to customize them. It must be noted that, if the customized values are incorrect, it could lead to an unpredictable behaviour when converting back to maxon::UniversalDateTime.
Creation and initialization
A maxon::LocalDateTime can be created and initialized using:
const UInt64 aTimeStamp(1467363600);
const
maxon::
String timedateStr = "2016-07-01 09:00:00"_s;
const
Char* timedateFrmtStr = "%Y-%
m-%d %H:%
M:%
S";
const
maxon::LocalDateTime ldtFromString =
maxon::LocalDateTime::FromString(timedateStr, timedateFrmtStr)
iferr_return;
const char * m
Definition: abstract.h:692
Definition: c4d_string.h:39
Definition: datetime.h:91
static LocalDateTime GetNow()
static Result< LocalDateTime > FromValues(Int32 year, UChar month, UChar day, UChar hour, UChar minute, UChar second, DST daylightSavingTime=DST::AUTOMATIC)
static LocalDateTime FromUnixTimestamp(UInt64 timestamp)
M
Meter.
Definition: customgui_unitscale.h:2
maxon::UInt64 UInt64
Definition: ge_sys_math.h:63
maxon::Char Char
Definition: ge_sys_math.h:56
S
Scale morphing.
Definition: lib_ca.h:1
The maxon namespace contains all declarations of the MAXON API.
Definition: autoweight.h:14
#define iferr_return
Definition: resultbase.h:1519
Comparison
A maxon::LocalDateTime can be compared by using standard operators:
const UInt64 timestamp = 1467363600;
ldtAnother._hour -= 2;
if (ldt == ldtCloned)
{
}
if (ldtAnother != ldt)
{
DiagnosticOutput(
"ldtAnother time/date values are different than those stored in ldt.");
}
#define DiagnosticOutput(formatString,...)
Definition: debugdiagnostics.h:176
Conversion
A maxon::LocalDateTime can be converted to maxon::UniversalDateTime using:
Definition: datetime.h:231
Similarly the following methods return maxon::String representations of the maxon::LocalDateTime via:
- Note
- maxon::LocalDateTime::FormatTime() uses the same formatting specified in C++ strftime() function.
const UInt64 timestamp = 1467363600;
String ToString(const FormatStatement *formatStatement=nullptr) const
String FormatTime(const Char *formatString) const
Definition: string.h:1235
Utilities
A few helpful methods are provided with the maxon::LocalDateTime as utilities:
if (isLeapYear)
else
const maxon::TimeValue timezoneOffset = ldtNow.GetTimezoneOffset(&isDSTaffecting);
if (isDSTaffecting)
DiagnosticOutput(
"Local date/time is offsetted by @h respect to UTC and DST is affecting the offset", timezoneOffset.
GetHours());
else
if (isAnotherLeapYear)
else
switch (dayOfWeek)
{
dayStr = "Monday"_s;
break;
dayStr = "Tuesday"_s;
break;
dayStr = "Wednesday"_s;
break;
dayStr = "Thursday"_s;
break;
dayStr = "Friday"_s;
break;
dayStr = "Saturday"_s;
break;
dayStr = "Sunday"_s;
break;
}
DAYOFWEEK GetDayOfWeek() const
The TimeValue class encapsulates a timer value.
Definition: timevalue.h:33
Float64 GetHours() const
Definition: timevalue.h:180
maxon::UChar UChar
Definition: ge_sys_math.h:57
maxon::Int32 Int32
Definition: ge_sys_math.h:60
bool Bool
boolean type, possible values are only false/true, 8 bit
Definition: apibase.h:181
UInt64 UInt
unsigned 32/64 bit int, size depends on the platform
Definition: apibase.h:189
DAYOFWEEK
Day of Week.
Definition: datetime.h:15
Further Reading