nlib
|
The class for representing the date and time. More...
#include "nn/nlib/DateTime.h"
Public Types | |
enum | Week { WEEK_SUNDAY = 0, WEEK_MONDAY, WEEK_TUESDAY, WEEK_WEDNESDAY, WEEK_THURSDAY, WEEK_FRIDAY, WEEK_SATURDAY } |
Constants representing the days of the week. More... | |
Public Member Functions | |
errno_t | Init (int year, int month, int day, int hour=0, int min=0, int sec=0, int msec=0, int usec=0) noexcept |
Initializes the time. More... | |
errno_t | Init (const DateTimeParams &rhs) noexcept |
Initializes the date and time using the DateTimeParams structure. Returns EINVAL if given an invalid date. | |
errno_t | Init (const TimeValue &tv) noexcept |
Initializes the date and time using the TimeValue structure. Returns EINVAL if given an invalid date. | |
errno_t | GetDay (int *year, int *month, int *day) const noexcept |
Gets the year, month, and day. More... | |
errno_t | GetTime (int *hour, int *min, int *sec, int *msec, int *usec) const noexcept |
Gets the time. More... | |
errno_t | Get (DateTimeParams *rhs) const noexcept |
Gets the time. More... | |
TimeValue | ToTimeValue () const noexcept |
Returns a TimeValue object. | |
bool | IsValid () const noexcept |
Checks whether the time is valid. More... | |
errno_t | GetDayOfYear (int *nth) const noexcept |
Gets the day of the year based on the specified date and time. More... | |
errno_t | GetDayOfWeek (Week *week) const noexcept |
Gets what day of the week it is. More... | |
errno_t | Add (const TimeSpan &rhs) noexcept |
Adds the duration specified in rhs to the date and time. More... | |
errno_t | AddYears (int value) noexcept |
Adds the number of years specified in value to the date and time. More... | |
errno_t | AddMonths (int value) noexcept |
Adds the number of months specified in value to the date and time. More... | |
errno_t | AddDays (double value) noexcept |
Adds the number of days specified in value to the date and time. More... | |
errno_t | AddHours (double value) noexcept |
Adds the number of hours specified in value to the date and time. More... | |
errno_t | AddMinutes (double value) noexcept |
Adds the number of minutes specified in value to the date and time. More... | |
errno_t | AddSeconds (double value) noexcept |
Adds the number of seconds specified in value to the date and time. More... | |
errno_t | AddMilliSeconds (double value) noexcept |
Adds the number of milliseconds specified in value to the date and time. More... | |
errno_t | AddMicroSeconds (double value) noexcept |
Adds the number of microseconds specified in value to the date and time. More... | |
errno_t | ToW3cDtf (char(&str)[32], const TimeSpan &zone) const noexcept |
Outputs the date and time as a string in W3CDTF format. More... | |
errno_t | ToW3cDtf (char(&str)[32]) const noexcept |
Calls ToW3cDtf(str, TimeSpan()) . | |
errno_t | ToRfc2822 (char(&str) [32], const TimeSpan &zone) const noexcept |
Outputs the date and time as a string in RFC 2822 format. More... | |
errno_t | ToRfc2822 (char(&str)[32]) const noexcept |
Calls ToRfc2822(str, TimeSpan()) . | |
errno_t | ToAscTime (char(&str)[26]) const noexcept |
Outputs the date and time as a string in asctime format. Note that the string ends with a newline character. More... | |
operator bool () const | |
Returns true if the time being held is valid. | |
DateTime & | operator+= (const TimeSpan &rhs) noexcept |
Adds the time indicated by rhs. | |
DateTime & | operator-= (const TimeSpan &rhs) noexcept |
Subtracts the time indicated by rhs. | |
bool | operator== (const DateTime &rhs) const noexcept |
Returns true if the time is equal to rhs. | |
bool | operator!= (const DateTime &rhs) const noexcept |
Returns true if the time is not equal to rhs. | |
bool | operator< (const DateTime &rhs) const noexcept |
Returns true if further in the past than rhs. | |
bool | operator> (const DateTime &rhs) const noexcept |
Returns true if further in the future than rhs. | |
bool | operator<= (const DateTime &rhs) const noexcept |
Returns true if the same or further in the past than rhs. | |
bool | operator>= (const DateTime &rhs) const noexcept |
Returns true if the same or further in the future than rhs. | |
DateTime (const struct timespec *tm) noexcept | |
Instantiates the object from the timespec structure. | |
void | ToTimeSpec (struct timespec *tm) const noexcept |
Converts to a value of the timespec structure. | |
Basic Member Functions | |
constexpr | DateTime () noexcept |
Instantiates the object with default parameters (default constructor). Initializes with an invalid time. | |
Static Public Member Functions | |
static bool | IsLeapYear (int year) noexcept |
Checks whether the specified year is a leap year. More... | |
static errno_t | GetNow (DateTime *p) noexcept |
Sets the DateTime object based on the current time. More... | |
static int | GetDaysInMonth (int year, int month) noexcept |
Gets the number of days in a particular month, based on the specified year and month. More... | |
static errno_t | Parse (const char *str, DateTime *dt, TimeSpan *delta) noexcept |
Parses the string that denotes the date and time and sets it in a DateTime object and a TimeSpan object. More... | |
The class for representing the date and time.
TimeSpan
objects is also supported. Definition at line 248 of file DateTime.h.
Constants representing the days of the week.
Enumerator | |
---|---|
WEEK_SUNDAY | Sunday. |
WEEK_MONDAY | Monday. |
WEEK_TUESDAY | Tuesday. |
WEEK_WEDNESDAY | Wednesday. |
WEEK_THURSDAY | Thursday. |
WEEK_FRIDAY | Friday. |
WEEK_SATURDAY | Saturday. |
Definition at line 251 of file DateTime.h.
|
inlinenoexcept |
Adds the duration specified in rhs to the date and time.
[in] | rhs | A duration of time. |
0
if successful, or ERANGE
if DateTime
is or will be invalid. Definition at line 402 of file DateTime.h.
|
inlinenoexcept |
Adds the number of days specified in value to the date and time.
[in] | value | A number of days. |
0
if successful, or ERANGE
if DateTime
is or will be invalid. Definition at line 407 of file DateTime.h.
|
inlinenoexcept |
Adds the number of hours specified in value to the date and time.
[in] | value | A number of hours. |
0
if successful, or ERANGE
if DateTime
is or will be invalid. Definition at line 413 of file DateTime.h.
|
inlinenoexcept |
Adds the number of microseconds specified in value to the date and time.
[in] | value | A number of microseconds. |
0
if successful, or ERANGE
if DateTime
is or will be invalid. Definition at line 437 of file DateTime.h.
|
inlinenoexcept |
Adds the number of milliseconds specified in value to the date and time.
[in] | value | A number of milliseconds. |
0
if successful, or ERANGE
if DateTime
is or will be invalid. Definition at line 431 of file DateTime.h.
|
inlinenoexcept |
Adds the number of minutes specified in value to the date and time.
[in] | value | A number of minutes. |
0
if successful, or ERANGE
if DateTime
is or will be invalid. Definition at line 419 of file DateTime.h.
|
noexcept |
Adds the number of months specified in value to the date and time.
[in] | value | A number of months. |
0
if successful, or ERANGE
if DateTime
is or will be invalid.
|
inlinenoexcept |
Adds the number of seconds specified in value to the date and time.
[in] | value | A number of seconds. |
0
if successful, or ERANGE
if DateTime
is or will be invalid. Definition at line 425 of file DateTime.h.
|
noexcept |
Adds the number of years specified in value to the date and time.
[in] | value | A number of years. |
0
if successful, or ERANGE
if DateTime
is or will be invalid.
|
noexcept |
Gets the time.
[out] | rhs | The pointer to the structure when the time is written. |
0
if successful, or ERANGE
if DateTime
is invalid.
|
noexcept |
Gets the year, month, and day.
[out] | year | The year (1-9999). |
[out] | month | The month (1-12). |
[out] | day | The day (1-). |
0
if successful, or ERANGE
if DateTime
is invalid.
|
noexcept |
Gets what day of the week it is.
[out] | week | The day of the week. |
0
if successful, or ERANGE
if DateTime
is invalid.
|
noexcept |
Gets the day of the year based on the specified date and time.
[out] | nth | The number of days since the start of the specified year, counted starting from 0. |
0
if successful, or ERANGE
if DateTime
is invalid.
|
staticnoexcept |
Gets the number of days in a particular month, based on the specified year and month.
[in] | year | A year. |
[in] | month | A month. |
0
if there was an error.
|
staticnoexcept |
|
noexcept |
Gets the time.
[out] | hour | The hour (1-23). |
[out] | min | The minute (0-59). |
[out] | sec | The second (0-59). |
[out] | msec | The millisecond (0-999). |
[out] | usec | The microsecond (0-999). |
0
if successful, or ERANGE
if DateTime
is invalid.
|
noexcept |
Initializes the time.
[in] | year | The year (1-1999). |
[in] | month | The month (1-12). |
[in] | day | The day (1-). |
[in] | hour | The hour (0-23). |
[in] | min | The minute (0-59). |
[in] | sec | The second (0-59). |
[in] | msec | The millisecond (0-999). |
[in] | usec | The microsecond (0-999999). |
0
if successful, or EINVAL
if an invalid date and time has been specified.
|
inlinestaticnoexcept |
Checks whether the specified year is a leap year.
[in] | year | The year to check. |
true
if it is a leap year, and false
otherwise. Definition at line 382 of file DateTime.h.
|
noexcept |
Checks whether the time is valid.
true
if the time is valid (that is, some time between 00::00 of January 1 of the year 1 and 23:59:59.999 of December 31 of the year 9999). Parses the string that denotes the date and time and sets it in a DateTime
object and a TimeSpan
object.
[in] | str | A string denoting the date and time. |
[out] | dt | Stores the date and time information. |
[out] | delta | Stores the time zone information (for example, +09:00 hours). |
0
if successful, and some other value if there was an error.W3C-DTF
, RFC2822
, or asctime
format.
|
noexcept |
Outputs the date and time as a string in asctime
format. Note that the string ends with a newline character.
[out] | str | The buffer for the 26-byte output string. |
0
if successful, or ERANGE
if DateTime
is invalid.
|
noexcept |
Outputs the date and time as a string in RFC 2822 format.
[out] | str | The buffer for the 32-byte output string. |
[in] | zone | The time zone. |
0
if successful, or ERANGE
if DateTime
is invalid.
|
noexcept |
Outputs the date and time as a string in W3CDTF format.
[out] | str | The buffer for the 32-byte output string. |
[in] | zone | The time zone. |
0
if successful, or ERANGE
if DateTime
is invalid. © 2012-2016 Nintendo Co., Ltd. All rights reserved.