The datetime type represents a calendar date and time. It can be used to do math operations with dates, such as comparing two dates, determining the difference between dates, and addition/substraction on dates to form new dates.
It can also be used to get the current system time and thus allow measuring time for tasks, albeit with a rather low precision of seconds only.
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 in the universal time zone (UTC). If you need to consider a specific timezone with or without daylight savings then remember to adjust the time accordingly by adding the number of seconds for the difference.
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 property
Returns the year of the date stored in the object.
uint get_month() const property
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 property
Returns the day of the month of the date stored in the object.
uint get_hour() const property
Returns the hour of the time stored in the object. The range is 0 to 23.
uint get_minute() const property
Returns the minute of the time stored in the object. The range is 0 to 59.
uint get_second() const property
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.