class DateTime

Provides functions to manipulate, compare and output dates and times.

The underlying system time can handle dates back to January, 1st, 1601. However, some methods rely on converting the time to Unix time, which cannot express dates before January, 1st, 1970. If not stated otherwise, methods rely on the system time.

Global Functions

int Compare (const var, const var)Compares two DateTime objects.
DateTime CurrentTime ()Returns the current time as a new DateTime object.
float Difference (const DateTime, const DateTime)Returns the difference between the two DateTime objects in seconds.

Constructors

DateTime (const int, const int, const int, const int, const int, const int)Constructs a DateTime instance from the specified values.
DateTime (const DateTime)Copy-constructs an instance from the specified DateTime instance.
DateTime (const float)Constructs a new instance from the specified number of seconds.

Convertors

string convertor ()Returns a string representation of this instance.

Methods

DateTime AddDays (const float)Adds the given number of days to this instance and returns the result as a new instance.
DateTime AddHours (const float)Adds the given number of hours to this instance and returns the result as a new instance.
DateTime AddMinutes (const float)Adds the given number of minutes to this instance and returns the result as a new instance.
DateTime AddSeconds (const float)Adds the given number of seconds to this instance and returns the result as a new instance.
string Format (const string)Formats this instance using ANSI time format identifiers.
float ToFloat ()Converts this instance into a floating point number.

Properties

int Day ()Returns this instance's day property.
int DayOfWeek ()Returns this instance's day of the week property.
int DayOfYear ()Returns this instance's day of the year.
int Hour ()Returns this instance's hour property.
int IsLeapYear ()Returns true if this instance's year is a leap year.
int Millisecond ()Returns this instance's millisecond property.
int Minute ()Returns this instance's minute property.
int Month ()Returns this instance's month property.
int Second ()Returns this instance's second property.
int Year ()Returns this instance's year property.

Reference

function int Compare (const var value1, const var value2)

Compares two DateTime objects.

If the first date is before the second, returns -1. If it is after the second, returns 1. If they are equal, returns 0. This can be used as a comparator delegate for the array::sort() and list::sort() methods.


function DateTime CurrentTime ()

Returns the current time as a new DateTime object.


function float Difference (const DateTime d1, const DateTime d2)

Returns the difference between the two DateTime objects in seconds.

The second argument is subtracted from the first.


method DateTime (const int year, const int month, const int day, const int hour, const int minute, const int second)

Constructs a DateTime instance from the specified values.


method DateTime (const DateTime src)

Copy-constructs an instance from the specified DateTime instance.


method DateTime (const float seconds)

Constructs a new instance from the specified number of seconds.

The specified value represents the number of seconds that have elapsed since January, 1st, 1970 (Unix time).


method string convertor ()

Returns a string representation of this instance.

This method relies on Unix time. Uses the standard format: %Y-%m-%dT%H:%M:%S.


method DateTime AddDays (const float d)

Adds the given number of days to this instance and returns the result as a new instance.


method DateTime AddHours (const float h)

Adds the given number of hours to this instance and returns the result as a new instance.


method DateTime AddMinutes (const float m)

Adds the given number of minutes to this instance and returns the result as a new instance.


method DateTime AddSeconds (const float s)

Adds the given number of seconds to this instance and returns the result as a new instance.


method string Format (const string format)

Formats this instance using ANSI time format identifiers.

This method relies on Unix time.


method float ToFloat ()

Converts this instance into a floating point number.

The returned value represents the number of seconds that have elapsed since January, 1st, 1970 (Unix time).


accessor int Day ()

Returns this instance's day property.


accessor int DayOfWeek ()

Returns this instance's day of the week property.

The result is an integer between 0 and 6, where 0 represents the first day of the week (Sunday).


accessor int DayOfYear ()

Returns this instance's day of the year.


accessor int Hour ()

Returns this instance's hour property.


accessor int IsLeapYear ()

Returns true if this instance's year is a leap year.


accessor int Millisecond ()

Returns this instance's millisecond property.


accessor int Minute ()

Returns this instance's minute property.


accessor int Month ()

Returns this instance's month property.


accessor int Second ()

Returns this instance's second property.


accessor int Year ()

Returns this instance's year property.