Path: /sdk/add_on/datetime/
The CDateTime
class provides a way for scripts to get the system date and time.
Register the type with the RegisterScriptDateTime(asIScriptEngine*)
function.
class datetime { datetime(); datetime(const datetime &in other); datetime(uint y, uint m, uint d, uint h = 0, uint mi = 0, uint s = 0);
datetime &opAssign(const datetime &in other);
uint get_year() const; uint get_month() const; uint get_day() const; uint get_hour() const; uint get_minute() const; uint get_second() const;
bool setDate(uint year, uint month, uint day); bool setTime(uint hour, uint minute, uint second);
int64 opSub(const datetime &in) const; datetime opAdd(int64 seconds) const; datetime opAdd_r(int64 seconds) const; datetime &opAddAssign(int64 seconds); datetime opSub(int64 seconds) const; datetime opSub_r(int64 seconds) const; datetime &opSubAssign(int64 seconds); bool opEquals(const datetime &in) const; int opCmp(const datetime &in) const; }
datetime()
datetime(const datetime &in other)
datetime(uint y, uint m, uint d, uint h = 0, uint mi = 0, uint s = 0)
The default constructor initializes the object with the current system time.
The copy constructor copĂes the content of the other object.
The set constructor initializes the object with the given date and time.
uint get_year() const
Returns the year of the date stored in the object.
uint get_month() const
Returns the month of the date stored in the object. The range is 1 to 12, i.e. 1 is January, 12 is December, and so on.
uint get_day() const
Returns the day of the month of the date stored in the object.
uint get_hour() const
Returns the hour of the time stored in the object. The range is 0 to 23.
uint get_minute() const
Returns the minute of the time stored in the object. The range is 0 to 59.
uint get_second() const
Returns the second of the time stored in the object. The range is 0 to 59.
bool setDate(uint year, uint month, uint day)
bool setTime(uint hour, uint minute, uint second)
Sets the date or time. Returns true if the specified date or time is valid. Does not modify the object if not valid.
= assignment
The assignment operator copies the content of the other object.
- difference
When subtracting one datetime object from another the result is the number of seconds between them.
+ add
- subtract
+= add assign
-= subtract assign
The datetime object can be added or subtracted with seconds to form a new datetime object.
==, != equality
<, <=, >=, > comparison
The datetime object can be compared for equality or relativity.