Date and Time

// Date and time.
class RVAPI DateTime
{
public:
    // Milliseconds since 1900.
    slong timestamp;

    // Check if year is a leap year.
    static bool IsLeapYear(uint year);

    // Get date part of date time. Time is set to midnight.
    DateTime GetDate() const;

    // Get year.
    uint GetYear() const;

    // Get month (1 based).
    uint GetMonth() const;

    // Get day (1 based).
    uint GetDay() const;

    // Get hour (0 based).
    uint GetHour() const;

    // Get minute (0 based).
    uint GetMinutes() const;

    // Get second (0 based).
    uint GetSeconds() const;

    // Get day of Year (1 based).
    uint GetDayOfYear() const;

    // Get day of week (1 based).
    uint GetDayOfWeek() const;

    // Get full years from this date/time to [dateTime].
    int GetYearsDiff(const DateTime &dateTime) const;

    // Get full months from this date/time to [dateTime].
    int GetMonthsDiff(const DateTime &dateTime) const;

    // Get full days from this date/time to [dateTime].
    int GetDaysDiff(const DateTime &dateTime) const;

    // Get full hours from this date/time to [dateTime].
    int GetHoursDiff(const DateTime &dateTime) const;

    // Get full minutes from this date/time to [dateTime].
    int GetMinsDiff(const DateTime &dateTime) const;

    // Get full seconds from this date/time to [dateTime].
    int GetSecsDiff(const DateTime &dateTime) const;

    // Get minimum of this date/time and [dateTime].
    DateTime GetMin(const DateTime &dateTime) const;

    // Get maximum of this date/time and [dateTime].
    DateTime GetMax(const DateTime &dateTime) const;

    // Get first day of month.
    DateTime GetFirstOfMonth() const;

    // Get last day of month.
    DateTime GetEndOfMonth() const;

    // Get date/time string. [format] contains wcsftime date/time format specifiers.
    DateTime ToString(String &string, wcstr format) const;

    // Check if this dateTime is less than [dateTime].
    bool operator < (const DateTime &dateTime) const { return timestamp < dateTime.timestamp; }

    // Check if this dateTime is less than or equal to [dateTime].
    bool operator <= (const DateTime &dateTime) const { return timestamp <= dateTime.timestamp; }

    // Check if this dateTime is equal to [dateTime].
    bool operator == (const DateTime &dateTime) const { return timestamp == dateTime.timestamp; }

    // Check if this dateTime is not equal to [dateTime].
    bool operator != (const DateTime &dateTime) const { return timestamp != dateTime.timestamp; }

    // Check if this dateTime is greater than or equal to [dateTime].
    bool operator >= (const DateTime &dateTime) const { return timestamp >= dateTime.timestamp; }

    // Check if this dateTime is greater than [dateTime].
    bool operator > (const DateTime &dateTime) const { return timestamp > dateTime.timestamp; }

    // Get difference of this string and [dateTime].
    DateTime operator - (const DateTime &dateTime) const { return DateTime(timestamp - dateTime.timestamp); }

    // Add years to this date/time.
    DateTime AddYears(int years) const;

    // Add months to this date/time.
    DateTime AddMonths(int months) const;

    // Add days to this date/time.
    DateTime AddDays(int days) const;

    // Add hours to this date/time.
    DateTime AddHours(int hours) const;

    // Add minutes to this date/time.
    DateTime AddMins(int mins) const;

    // Add seconds to this date/time.
    DateTime AddSecs(int secs) const;

    // Set this date/time using date and time components.
    DateTime Set(uint year, uint month, uint day, uint hour = 0, uint min = 0, uint sec = 0);

    // Set this date/time using date/time string.
    DateTime Set(wcstr format);

    // Construct date/time using date and time components.
    DateTime(uint year, uint month, uint day, uint hour = 0, uint min = 0, uint sec = 0)
    {
        Set(year, month, day, hour, min, sec);
    }

    // Construct date/time using timestamp.
    DateTime(slong timestamp) : timestamp(timestamp) {}

    // Construct date/time using date/time string.
    DateTime(wcstr string);

    // Constuct date/time using current date and time.
    DateTime() {}

    // Destructor.
    ~DateTime() {}
};