/*---------------------------------------------------------------------------* Copyright (C) 2013-2014 Nintendo. All rights reserved. These coded instructions, statements, and computer programs contain proprietary information of Nintendo of America Inc. and/or Nintendo Company Ltd., and are protected by Federal copyright law. They may not be disclosed to third parties or copied or duplicated in any form, in whole or in part, without the prior written consent of Nintendo. *---------------------------------------------------------------------------*/ #ifndef NN_EC_DATE_TIME_H_ #define NN_EC_DATE_TIME_H_ #include namespace nn { namespace ec { //! @addtogroup nn_ec_class //! @{ /*! @brief Class for handling the date and time. */ class DateTime : public RootObject { public: /*! @brief The day of the week. */ enum Week { WEEK_SUNDAY = 0, //!< Sunday. WEEK_MONDAY = 1, //!< Monday. WEEK_TUESDAY = 2, //!< Tuesday. WEEK_WEDNESDAY = 3, //!< Wednesday. WEEK_THURSDAY = 4, //!< Thursday. WEEK_FRIDAY = 5, //!< Friday. WEEK_SATURDAY = 6, //!< Saturday. WEEK_MAX, WEEK_FORCE_S32 = 0x7FFFFFFF }; public: /*! @brief Instantiates the object. The initial value is set to 2010-01-01 00:00:00. */ DateTime(); /*! @brief Instantiates the object. @param[in] pFormatted Specifies a formatted string. @n The "YYYY-MM-DD" and "YYYY-MM-DD hh:mm:ss" formats are supported. */ DateTime(const char* pFormatted); /*! @brief Instantiates the object. @param[in] year Specifies the year. @n The valid range is from 0 through 9999. @param[in] month Specifies the month. @n The valid range is from 1 through 12. @param[in] day Specifies the day. @n The valid range is from 1 through 31. @param[in] hour Specifies the hour. @n The valid range is from 0 through 23. @param[in] minute Specifies the minute. @n The valid range is from 0 through 59. @param[in] second Specifies the second. @n The valid range is from 0 through 59. */ DateTime(u16 year, u8 month, u8 day, u8 hour = 0, u8 minute = 0, u8 second = 0); /*! @brief Gets the year. The valid range is from 0 through 9999. @return Returns the year. */ u16 GetYear() const; /*! @brief Gets the month. The valid range is from 1 through 12. @return Returns the month. */ u8 GetMonth() const; /*! @brief Gets the day. The valid range is from 1 through 31. @return Returns the day. */ u8 GetDay() const; /*! @brief Gets the hour. The valid range is from 0 through 23. @return Returns the hour. */ u8 GetHour() const; /*! @brief Gets the minute. The valid range is from 0 through 59. @return Returns the minute. */ u8 GetMinute() const; /*! @brief Gets the second. The valid range is from 0 through 59. @return Returns the second. */ u8 GetSecond() const; /*! @brief Gets the name of the day of the week. @return Returns the day of the week. */ Week GetWeek() const; /*! @brief Compares two DateTime objects. @param[in] dateTime Specifies the date and time to compare. @return Returns the result of an equality (==) operation. */ bool operator==(const DateTime& dateTime) const; /*! @brief Compares two DateTime objects. @param[in] dateTime Specifies the date and time to compare. @return Returns the result of an inequality (!=) operation. */ bool operator!=(const DateTime& dateTime) const; /*! @brief Compares two DateTime objects. @param[in] dateTime Specifies the date and time to compare. @return Returns the result of a greater than (>) operation. */ bool operator>(const DateTime& dateTime) const; /*! @brief Compares two DateTime objects. @param[in] dateTime Specifies the date and time to compare. @return Returns the result of a less than (<) operation. */ bool operator<(const DateTime& dateTime) const; /*! @brief Compares two DateTime objects. @param[in] dateTime Specifies the date and time to compare. @return Returns the result of a greater-than-or-equal-to (>=) operation. */ bool operator>=(const DateTime& dateTime) const; /*! @brief Compares two DateTime objects. @param[in] dateTime Specifies the date and time to compare. @return Returns the result of a less-than-or-equal-to (<=) operation. */ bool operator<=(const DateTime& dateTime) const; /*! @brief Adds time. @param[in] seconds Specifies the amount of time to add. @return Returns the date and time. */ const DateTime operator+(s64 seconds) const; /*! @brief Subtracts time. @param[in] seconds Specifies the amount of time to subtract. @return Returns the date and time. */ const DateTime operator-(s64 seconds) const; /*! @brief Subtracts one DateTime object from another and calculates the time difference. The time difference is returned as seconds. @param[in] dateTime Specifies the date and time to compare. @return Returns the time difference. */ s64 operator-(const DateTime& dateTime) const; /*! @brief Adds time. @param[in] seconds Specifies the amount of time to add. @return Returns the date and time. */ DateTime& operator+=(s64 seconds); /*! @brief Subtracts time. @param[in] seconds Specifies the amount of time to subtract. @return Returns the date and time. */ DateTime& operator-=(s64 seconds); private: // 0-9999 u16 m_year; // 1-12 u8 m_month; // 1-31 u8 m_day; // 0-23 u8 m_hour; // 0-59 u8 m_minute; // 0-59 u8 m_second; // u8 m_week; }; //! @} }} // namespace nn::ec #endif // NN_EC_DATE_TIME_H_