Represents an instant in time, typically expressed as a date and time of day.
Public Fields | |
static const date_time | max_value |
Represents the largest possible value of xtd::date_time. This field is read-only. | |
static const date_time | min_value |
Represents the smallest possible value of xtd::date_time. This field is read-only. | |
Public Constructors | |
date_time ()=default | |
Initializes a new instance of the xtd::date_time structure. | |
date_time (int64 ticks) | |
Initializes a new instance of the xtd::date_time structure to a specified number of ticks. | |
date_time (xtd::ticks ticks) | |
Initializes a new instance of the xtd::date_time structure to a specified number of ticks. | |
date_time (int64 ticks, xtd::date_time_kind kind) | |
Initializes a new instance of the xtd::date_time structure to a specified number of ticks and to Coordinated Universal Time (UTC) or local time. | |
date_time (xtd::ticks ticks, xtd::date_time_kind kind) | |
Initializes a new instance of the xtd::date_time structure to a specified number of ticks and to Coordinated Universal Time (UTC) or local time. | |
date_time (uint32 year, uint32 month, uint32 day) | |
Initializes a new instance of the xtd::date_time structure to the specified year, month, and day. | |
date_time (uint32 year, uint32 month, uint32 day, uint32 hour, uint32 minute, uint32 second) | |
Initializes a new instance of the xttd::date_time structure to the specified year, month, day, hour, minute, and second. | |
date_time (uint32 year, uint32 month, uint32 day, uint32 hour, uint32 minute, uint32 second, date_time_kind kind) | |
Initializes a new instance of the xtd::date_time structure to the specified year, month, day, hour, minute, second, and Coordinated Universal Time (UTC) or local time. | |
date_time (uint32 year, uint32 month, uint32 day, uint32 hour, uint32 minute, uint32 second, uint32 millisecond) | |
Initializes a new instance of the xtd::date_time structure to the specified year, month, day, hour, minute, second, and millisecond. | |
date_time (uint32 year, uint32 month, uint32 day, uint32 hour, uint32 minute, uint32 second, uint32 millisecond, date_time_kind kind) | |
Initializes a new instance of the xtd::date_time structure to the specified year, month, day, hour, minute, second, millisecond, and Coordinated Universal Time (UTC) or local time. | |
Public Properties | |
date_time | date () const noexcept |
Gets the date component of this instance. | |
uint32 | day () const noexcept |
Gets the day of the month represented by this instance. | |
xtd::day_of_week | day_of_week () const noexcept |
Gets the day of the week represented by this instance. | |
uint32 | day_of_year () const noexcept |
Gets the day of the year represented by this instance. | |
uint32 | hour () const noexcept |
Gets the hour component of the date represented by this instance. | |
date_time_kind | kind () const noexcept |
Gets a value that indicates whether the time represented by this instance is based on local time, Coordinated Universal Time (UTC), or neither. | |
uint32 | millisecond () const noexcept |
Gets the milliseconds component of the date represented by this instance. | |
uint32 | minute () const noexcept |
Gets the minute component of the date represented by this instance. | |
uint32 | month () const noexcept |
Gets the month component of the date represented by this instance. | |
uint32 | second () const noexcept |
Gets the seconds component of the date represented by this instance. | |
int64 | ticks () const noexcept |
Gets the number of ticks that represent the date and time of this instance. | |
xtd::ticks | ticks_duration () const noexcept |
Gets the number of ticks that represent the date and time of this instance. | |
xtd::time_span | time_of_day () const noexcept |
Gets the time of day for this instance. | |
uint32 | year () const noexcept |
Gets the year component of the date represented by this instance. | |
Public Methods | |
date_time | add (const xtd::time_span &value) const |
Returns a new xtd::date_time that adds the value of the specified xtd::time_span to the value of this instance. | |
date_time | add_days (double value) const |
Returns a new xtd::date_time that adds the specified number of days to the value of this instance. | |
date_time | add_hours (double value) const |
Returns a new xtd::date_time that adds the specified number of hours to the value of this instance. | |
date_time | add_milliseconds (double value) const |
Returns a new xtd::date_time that adds the specified number of milliseconds to the value of this instance. | |
date_time | add_minutes (double value) const |
Returns a new xtd::date_time that adds the specified number of minutes to the value of this instance. | |
date_time | add_months (int32 months) const |
Returns a new xtd::date_time that adds the specified number of months to the value of this instance. | |
date_time | add_seconds (double value) const |
Returns a new xtd::date_time that adds the specified number of seconds to the value of this instance. | |
date_time | add_ticks (int64 value) const |
Returns a new xtd::date_time that adds the specified number of ticks to the value of this instance. | |
date_time | add_years (int32 value) const |
Returns a new xtd::date_time that adds the specified number of years to the value of this instance. | |
int32 | compare_to (const date_time &value) const noexcept override |
Compares the current instance with another object of the same type. | |
bool | equals (const date_time &) const noexcept override |
Indicates whether the current object is equal to another object of the same type. | |
std::vector< string > | get_date_time_formats () const noexcept |
Converts the value of this instance to all the string representations supported by the standard date and time format specifiers. | |
bool | is_daylight_saving_time () const noexcept |
Indicates whether this instance of xtd::date_time is within the daylight saving time range for the current time zone. | |
xtd::time_span | subtract (const date_time &value) const |
Returns a new xtd::time_span that subtracts the specified date and time from the value of this instance. | |
date_time | subtract (const xtd::time_span &value) const |
Returns a new xtd::date_time that subtracts the specified duration from the value of this instance. | |
int64 | to_binary () const |
Serializes the current xtd::date_time object to a 64-bit binary value that subsequently can be used to recreate the xtd::date_time object. | |
int64 | to_file_time () const |
Converts the value of the current xtd::date_time object to a Windows file time. | |
int64 | to_file_time_utc () const |
Converts the value of the current xtd::date_time object to a Windows file time. | |
date_time | to_local_time () const |
Converts the value of the current xtd::date_time object to local time. | |
const xtd::string | to_long_date_string () const |
Converts the value of the current xtd::date_time object to its equivalent long date string representation. | |
const xtd::string | to_long_time_string () const |
Converts the value of the current xtd::date_time object to its equivalent long time string representation. | |
const xtd::string | to_short_date_string () const |
Converts the value of the current xtd::date_time object to its equivalent short date string representation. | |
const xtd::string | to_short_time_string () const |
Converts the value of the current xtd::date_time object to its equivalent short time string representation. | |
xtd::string | to_string () const noexcept override |
Converts the value of the current xtd::date_time object to its equivalent string representation using the formatting conventions of the current culture. | |
xtd::string | to_string (const string &format) const |
Converts the value of the current xtd::date_time object to its equivalent string representation using the specified format and the formatting conventions of the current culture. | |
xtd::string | to_string (const string &format, const std::locale &loc) const override |
Converts the value of the current xtd::date_time object to its equivalent string representation using the specified format and the formatting conventions of the current culture. | |
std::time_t | to_time_t () const |
Converts the value of the current xtd::date_time object to std::time_t. | |
std::tm | to_tm () const |
Converts the value of the current xtd::date_time object to std::tm. | |
date_time | to_universal_time () const |
Converts the value of the current xtd::date_time object to Coordinated Universal Time (UTC). | |
virtual bool | equals (const object &obj) const noexcept |
Determines whether the specified object is equal to the current object. | |
template<typename object_a_t , typename object_b_t > | |
static bool | equals (const object_a_t &object_a, const object_b_t &object_b) noexcept |
Determines whether the specified object instances are considered equal. | |
Public Static Methods | |
static date_time | now () noexcept |
Gets a xtd::date_time object that is set to the current date and time on this computer, expressed as the local time. | |
static date_time | today () noexcept |
Gets the current date. | |
static date_time | utc_now () noexcept |
Gets a xtd::date_time object that is set to the current date and time on this computer, expressed as the Coordinated Universal Time (UTC). | |
static int32 | days_in_month (uint32 year, month_of_year month) |
Returns the number of days in the specified month and year. | |
static int32 | days_in_month (uint32 year, uint32 month) |
Returns the number of days in the specified month and year. | |
static date_time | from_binary (int64 date_data) |
Deserializes a 64-bit binary value and recreates an original serialized xtd::date_time object. | |
static date_time | from_file_time (int64 file_time) |
Converts the specified Windows file time to an equivalent local time. | |
static date_time | from_file_time_utc (int64 file_time) |
Converts the specified Windows file time to an equivalent UTC time. | |
static date_time | from_duration (const time_span &value) |
Converts the specified xtd::time_span to an equivalent unspecified time. | |
static date_time | from_duration (const time_span &value, date_time_kind kind) |
Converts the specified xtd::time_span to an equivalent to Coordinated Universal Time (UTC) or local time.. | |
static date_time | from_time_t (std::time_t value) |
Converts the specified std::time_t to an equivalent unspecified time. | |
static date_time | from_time_t (std::time_t value, date_time_kind kind) |
Converts the specified std::time_t to an equivalent to Coordinated Universal Time (UTC) or local time. | |
static date_time | from_tm (const std::tm &value) |
Converts the specified std::tm to an equivalent unspecified time. | |
static date_time | from_tm (const std::tm &value, date_time_kind kind) |
Converts the specified std::tm to an equivalent to Coordinated Universal Time (UTC) or local time. | |
static bool | is_leap_year (uint32 year) |
Returns an indication whether the specified year is a leap year. | |
static date_time | parse (const xtd::string &s) |
Converts the string representation of a date and time to its xtd::date_time equivalent by using the conventions of the current culture. | |
static date_time | specify_kind (const date_time &value, date_time_kind kind) |
Creates a new xtd::date_time object that has the same number of ticks as the specified xtd::date_time, but is designated as either local time, Coordinated Universal Time (UTC), or neither, as indicated by the specified xtd::date_time_kind value. | |
static xtd::string | sprintf (const string &format, const date_time &value) |
Returns a xtd::string that represents the current xtd::date_time. | |
static bool | try_parse (const string &s, date_time &result) noexcept |
Converts the specified string representation of a date and time to its xtd::date_time equivalent and returns a value that indicates whether the conversion succeeded. | |
Additional Inherited Members | |
Public Member Functions inherited from xtd::object | |
object ()=default | |
Create a new instance of the ultimate base class object. | |
virtual size_t | get_hash_code () const noexcept |
Serves as a hash function for a particular type. | |
virtual type_object | get_type () const noexcept |
Gets the type of the current instance. | |
template<typename object_t > | |
xtd::uptr< object_t > | memberwise_clone () const |
Creates a shallow copy of the current object. | |
Public Member Functions inherited from xtd::icomparable< date_time > | |
Public Member Functions inherited from xtd::iequatable< date_time > | |
Public Member Functions inherited from xtd::iformatable | |
Static Public Member Functions inherited from xtd::object | |
template<typename object_a_t , typename object_b_t > | |
static bool | equals (const object_a_t &object_a, const object_b_t &object_b) noexcept |
Determines whether the specified object instances are considered equal. | |
template<typename object_a_t , typename object_b_t > | |
static bool | reference_equals (const object_a_t &object_a, const object_b_t &object_b) noexcept |
Determines whether the specified object instances are the same instance. | |
|
default |
Initializes a new instance of the xtd::date_time structure.
|
explicit |
Initializes a new instance of the xtd::date_time structure to a specified number of ticks.
ticks | A date and time expressed in the number of 100-nanosecond intervals that have elapsed since January 1, 0001 at 00:00:00.000 in the Gregorian calendar. |
xtd::argument_out_of_range_exception | ticks is less than xtd::date_time::min_value or greater than xtd::date_time::max_value. |
|
explicit |
Initializes a new instance of the xtd::date_time structure to a specified number of ticks.
ticks | A date and time expressed in the number of 100-nanosecond intervals that have elapsed since January 1, 0001 at 00:00:00.000 in the Gregorian calendar. |
xtd::argument_out_of_range_exception | ticks is less than xtd::date_time::min_value or greater than xtd::date_time::max_value. |
xtd::date_time::date_time | ( | int64 | ticks, |
xtd::date_time_kind | kind | ||
) |
Initializes a new instance of the xtd::date_time structure to a specified number of ticks and to Coordinated Universal Time (UTC) or local time.
ticks | A date and time expressed in the number of 100-nanosecond intervals that have elapsed since January 1, 0001 at 00:00:00.000 in the Gregorian calendar. |
kind | One of the enumeration values that indicates whether ticks specifies a local time, Coordinated Universal Time (UTC), or neither. |
xtd::argument_out_of_range_exception | ticks is less than xtd::date_time::min_value or greater than xtd::date_time::max_value. |
xtd::date_time::date_time | ( | xtd::ticks | ticks, |
xtd::date_time_kind | kind | ||
) |
Initializes a new instance of the xtd::date_time structure to a specified number of ticks and to Coordinated Universal Time (UTC) or local time.
ticks | A date and time expressed in the number of 100-nanosecond intervals that have elapsed since January 1, 0001 at 00:00:00.000 in the Gregorian calendar. |
kind | One of the enumeration values that indicates whether ticks specifies a local time, Coordinated Universal Time (UTC), or neither. |
xtd::argument_out_of_range_exception | ticks is less than xtd::date_time::min_value or greater than xtd::date_time::max_value. |
Initializes a new instance of the xtd::date_time structure to the specified year, month, and day.
year | The year (1 through 9999). |
month | The month (1 through 12). |
day | The day (1 through the number of days in month). |
xtd::argument_out_of_range_exception | year is less than 1 or greater than 9999. -or- month is less than 1 or greater than 12. -or- day is less than 1 or greater than the number of days in month. |
xtd::date_time::date_time | ( | uint32 | year, |
uint32 | month, | ||
uint32 | day, | ||
uint32 | hour, | ||
uint32 | minute, | ||
uint32 | second | ||
) |
Initializes a new instance of the xttd::date_time structure to the specified year, month, day, hour, minute, and second.
year | The year (1 through 9999). |
month | The month (1 through 12). |
day | The day (1 through the number of days in month). |
hour | The hours (0 through 23). |
minute | The minutes (0 through 59). |
second | The seconds (0 through 59). |
xtd::argument_out_of_range_exception | year is less than 1 or greater than 9999. -or- month is less than 1 or greater than 12. -or- day is less than 1 or greater than the number of days in month. -or- hour is less than 0 or greater than 23. -or- minute is less than 0 or greater than 59. -or- second is less than 0 or greater than 59. |
xtd::date_time::date_time | ( | uint32 | year, |
uint32 | month, | ||
uint32 | day, | ||
uint32 | hour, | ||
uint32 | minute, | ||
uint32 | second, | ||
date_time_kind | kind | ||
) |
Initializes a new instance of the xtd::date_time structure to the specified year, month, day, hour, minute, second, and Coordinated Universal Time (UTC) or local time.
year | The year (1 through 9999). |
month | The month (1 through 12). |
day | The day (1 through the number of days in month). |
hour | The hours (0 through 23). |
minute | The minutes (0 through 59). |
second | The seconds (0 through 59). |
kind | One of the enumeration values that indicates whether year, month, day, hour, minute and second specify a local time, Coordinated Universal Time (UTC), or neither. |
xtd::argument_out_of_range_exception | year is less than 1 or greater than 9999. -or- month is less than 1 or greater than 12. -or- day is less than 1 or greater than the number of days in month. -or- hour is less than 0 or greater than 23. -or- minute is less than 0 or greater than 59 -or- second is less than 0 or greater than 59. |
xtd::date_time::date_time | ( | uint32 | year, |
uint32 | month, | ||
uint32 | day, | ||
uint32 | hour, | ||
uint32 | minute, | ||
uint32 | second, | ||
uint32 | millisecond | ||
) |
Initializes a new instance of the xtd::date_time structure to the specified year, month, day, hour, minute, second, and millisecond.
year | The year (1 through 9999). |
month | The month (1 through 12). |
day | The day (1 through the number of days in month). |
hour | The hours (0 through 23). |
minute | The minutes (0 through 59). |
second | The seconds (0 through 59). |
millisecond | The milliseconds (0 through 999). |
xtd::argument_out_of_range_exception | year is less than 1 or greater than 9999. -or- month is less than 1 or greater than 12. -or- day is less than 1 or greater than the number of days in month. -or- hour is less than 0 or greater than 23. -or- minute is less than 0 or greater than 59 -or- second is less than 0 or greater than 59 -or- millisecond is less than 0 or greater than 999. |
xtd::date_time::date_time | ( | uint32 | year, |
uint32 | month, | ||
uint32 | day, | ||
uint32 | hour, | ||
uint32 | minute, | ||
uint32 | second, | ||
uint32 | millisecond, | ||
date_time_kind | kind | ||
) |
Initializes a new instance of the xtd::date_time structure to the specified year, month, day, hour, minute, second, millisecond, and Coordinated Universal Time (UTC) or local time.
year | The year (1 through 9999). |
month | The month (1 through 12). |
day | The day (1 through the number of days in month). |
hour | The hours (0 through 23). |
minute | The minutes (0 through 59). |
second | The seconds (0 through 59). |
millisecond | The milliseconds (0 through 999). |
kind | One of the enumeration values that indicates whether year, month, day, hour, minute and second specify a local time, Coordinated Universal Time (UTC), or neither. |
xtd::argument_out_of_range_exception | year is less than 1 or greater than 9999. -or- month is less than 1 or greater than 12. -or- day is less than 1 or greater than the number of days in month. -or- hour is less than 0 or greater than 23. -or- minute is less than 0 or greater than 59 -or- second is less than 0 or greater than 59 -or- millisecond is less than 0 or greater than 999. |
|
noexcept |
Gets the date component of this instance.
|
noexcept |
Gets the day of the month represented by this instance.
|
noexcept |
Gets the day of the week represented by this instance.
|
noexcept |
Gets the day of the year represented by this instance.
|
noexcept |
Gets the hour component of the date represented by this instance.
|
noexcept |
Gets a value that indicates whether the time represented by this instance is based on local time, Coordinated Universal Time (UTC), or neither.
|
noexcept |
Gets the milliseconds component of the date represented by this instance.
|
noexcept |
Gets the minute component of the date represented by this instance.
|
noexcept |
Gets the month component of the date represented by this instance.
|
noexcept |
Gets the seconds component of the date represented by this instance.
|
noexcept |
Gets the number of ticks that represent the date and time of this instance.
|
noexcept |
Gets the number of ticks that represent the date and time of this instance.
|
noexcept |
Gets the time of day for this instance.
|
noexcept |
Gets the year component of the date represented by this instance.
date_time xtd::date_time::add | ( | const xtd::time_span & | value | ) | const |
Returns a new xtd::date_time that adds the value of the specified xtd::time_span to the value of this instance.
value | A positive or negative time interval. |
xtd::argument_out_of_range_exception | The resulting xtd::date_time is less than xtd::date_time::min_value or greater than xtd::date_time::max_value. |
date_time xtd::date_time::add_days | ( | double | value | ) | const |
Returns a new xtd::date_time that adds the specified number of days to the value of this instance.
value | A number of whole and fractional days. The value parameter can be negative or positive. |
xtd::argument_out_of_range_exception | The resulting xtd::date_time is less than xtd::date_time::min_value or greater than xtd::date_time::max_value. |
date_time xtd::date_time::add_hours | ( | double | value | ) | const |
Returns a new xtd::date_time that adds the specified number of hours to the value of this instance.
value | A number of whole and fractional hours. The value parameter can be negative or positive.A number of whole and fractional hours. The value parameter can be negative or positive. |
xtd::argument_out_of_range_exception | The resulting xtd::date_time is less than xtd::date_time::min_value or greater than xtd::date_time::max_value. |
date_time xtd::date_time::add_milliseconds | ( | double | value | ) | const |
Returns a new xtd::date_time that adds the specified number of milliseconds to the value of this instance.
value | A number of whole and fractional milliseconds. The value parameter can be negative or positive. |
xtd::argument_out_of_range_exception | The resulting xtd::date_time is less than xtd::date_time::min_value or greater than xtd::date_time::max_value. |
date_time xtd::date_time::add_minutes | ( | double | value | ) | const |
Returns a new xtd::date_time that adds the specified number of minutes to the value of this instance.
value | A number of whole and fractional minutes. The value parameter can be negative or positive. |
xtd::argument_out_of_range_exception | The resulting xtd::date_time is less than xtd::date_time::min_value or greater than xtd::date_time::max_value. |
Returns a new xtd::date_time that adds the specified number of months to the value of this instance.
months | A number of months. The months parameter can be negative or positive. |
xtd::argument_out_of_range_exception | The resulting xtd::date_time is less than xtd::date_time::min_value or greater than xtd::date_time::max_value. -or- months is less than -120,000 or greater than 120,000. |
date_time xtd::date_time::add_seconds | ( | double | value | ) | const |
Returns a new xtd::date_time that adds the specified number of seconds to the value of this instance.
value | A number of whole and fractional seconds. The value parameter can be negative or positive. |
xtd::argument_out_of_range_exception | The resulting xtd::date_time is less than xtd::date_time::min_value or greater than xtd::date_time::max_value. |
Returns a new xtd::date_time that adds the specified number of ticks to the value of this instance.
value | A number of 100-nanosecond ticks. The value parameter can be positive or negative. |
xtd::argument_out_of_range_exception | The resulting xtd::date_time is less than xtd::date_time::min_value or greater than xtd::date_time::max_value. |
Returns a new xtd::date_time that adds the specified number of years to the value of this instance.
value | A number of years. The value parameter can be negative or positive. |
xtd::argument_out_of_range_exception | The resulting xtd::date_time is less than xtd::date_time::min_value or greater than xtd::date_time::max_value. |
Compares the current instance with another object of the same type.
obj | An object to compare with this instance. |
Value | Condition |
---|---|
Less than zero | This instance is less than obj. |
Zero | This instance is equal to obj. |
Greater than zero | This instance is greater than obj. |
Implements xtd::icomparable< date_time >.
|
overridevirtualnoexcept |
Indicates whether the current object is equal to another object of the same type.
obj | An object to compare with this object. |
true
if the current object is equal to the other parameter; otherwise, false
. Implements xtd::iequatable< date_time >.
|
noexcept |
Converts the value of this instance to all the string representations supported by the standard date and time format specifiers.
|
noexcept |
Indicates whether this instance of xtd::date_time is within the daylight saving time range for the current time zone.
xtd::time_span xtd::date_time::subtract | ( | const date_time & | value | ) | const |
Returns a new xtd::time_span that subtracts the specified date and time from the value of this instance.
value | The date and time value to subtract. |
xtd::argument_out_of_range_exception | The result is less than xtd::date_time:min_value or represents a time greater than xtd::date_time:max_value. |
date_time xtd::date_time::subtract | ( | const xtd::time_span & | value | ) | const |
Returns a new xtd::date_time that subtracts the specified duration from the value of this instance.
value | The time interval to subtract. |
xtd::argument_out_of_range_exception | The result is less than xtd::date_time:min_value or represents a time greater than xtd::date_time:max_value. |
int64 xtd::date_time::to_binary | ( | ) | const |
Serializes the current xtd::date_time object to a 64-bit binary value that subsequently can be used to recreate the xtd::date_time object.
int64 xtd::date_time::to_file_time | ( | ) | const |
Converts the value of the current xtd::date_time object to a Windows file time.
xtd::argument_out_of_range_exception | The resulting file time would represent a date and time before 12:00 midnight January 1, 1601 C.E. UTC. |
int64 xtd::date_time::to_file_time_utc | ( | ) | const |
Converts the value of the current xtd::date_time object to a Windows file time.
xtd::argument_out_of_range_exception | The resulting file time would represent a date and time before 12:00 midnight January 1, 1601 C.E. UTC. |
date_time xtd::date_time::to_local_time | ( | ) | const |
Converts the value of the current xtd::date_time object to local time.
Kind | Results |
---|---|
xtd::date_time_kind::utc | This instance of xtd::date_timextd::date_time is converted to local time. |
xtd::date_time_kind::local | No conversion is performed. |
xtd::date_time_kind::unspecified | This instance of xtd::date_time is assumed to be a UTC time, and the conversion is performed as if xtd::date_time::kind were xtd::date_time_kind::utc. |
const xtd::string xtd::date_time::to_long_date_string | ( | ) | const |
Converts the value of the current xtd::date_time object to its equivalent long date string representation.
const xtd::string xtd::date_time::to_long_time_string | ( | ) | const |
Converts the value of the current xtd::date_time object to its equivalent long time string representation.
const xtd::string xtd::date_time::to_short_date_string | ( | ) | const |
Converts the value of the current xtd::date_time object to its equivalent short date string representation.
const xtd::string xtd::date_time::to_short_time_string | ( | ) | const |
Converts the value of the current xtd::date_time object to its equivalent short time string representation.
|
overridevirtualnoexcept |
Converts the value of the current xtd::date_time object to its equivalent string representation using the formatting conventions of the current culture.
Reimplemented from xtd::object.
xtd::string xtd::date_time::to_string | ( | const string & | format | ) | const |
Converts the value of the current xtd::date_time object to its equivalent string representation using the specified format and the formatting conventions of the current culture.
format | A standard or custom date and time format string. |
xtd::format_excpetion | The length of format is 1, and it is not a valid format characters -or- The length si greater than 1. |
Format | |
---|---|
'a' | writes "PM" or "AM" |
'b' | writes 3 digit millisecond, e.G. 012 |
'B' | wrties millisecond, eg 12 |
'c' | writes 7 digit tick, e.G. 0000123 |
'C' | writes tick, e.G. 123 |
'd' | writes date MM/dd/y, e.g. 01/05/42 |
'D' | writes date M/dd/y, e.g. 1/055/42 |
'e' | writes 2 digit second, e.G. 03 |
'B' | writes second, e.G. 3 |
'f' | writes alternative date and time string, e.g. using 平成23年 (year Heisei 23) instead of 2011年 (year 2011) in ja_JP locale. |
'F' | writes standard date and time string, e.g. Sun Oct 17 04:41:13 2010 (locale dependent). |
'g' | writes alternative date and time string, e.g. using 平成23年 (year Heisei 23) instead of 2011年 (year 2011) in ja_JP locale. |
'G' | writes standard date and time string, e.g. Sun Oct 17 04:41:13 2010 (locale dependent). |
'h' | writes abbreviated weekday name, e.g. Fri (locale dependent). |
'H' | writes full weekday name, e.g. Friday (locale dependent). |
'i' | writes 2 digit day, e.g. 05 |
'I' | writes day, e.G. 5 |
'j' | writes abbreviated month name, e.g. Oct (locale dependent) |
'J' | writes full month name, e.g. October (locale dependent). |
'k' | writes 2 digit month, e.g. 01 |
'K' | writes month, e.g. 1 |
'l' | writes 2 digit year, e.g. 71 |
'L' | writes 4 digit year, e.g. 1971 |
'm' | writes year, e.g. 42 |
'M' | writes full month name and day, e.g. October, 5 (locale dependent). |
'n' | writes full weekday name, day, fulll month and year, e.g. Tuesday, 1 April 2008 |
'N' | writes full weekday name, day, fulll month, year, hour, minute ans second, e.g. Tuesday, 1 April 2008 18:07:05 |
'o' | writes day, full month and year, e.g. 5 January 42 |
'O' | writes day, full month and year, e.g. 5 January 42 |
'p' | writes 2 digit minute, e.G. 06 |
'P' | writes minute, e.G. 6 |
's' | writes sortable date/time pattern yyyy-MM-ddThh:mm:ss.ttttttt. e.g. 1971-05-01T21:32:24:42.004567 |
't' | writes time hh/mm/ss, e.g. 02:04:06 |
'T' | writes time h/mm/ss, e.g. 2:04:06 |
'u' | writes sortable short date/time pattern y-MM-dd hh:mm:ss. e.g. 1971-05-01 9:32:24:42 |
'U' | writes full weekday name, day, fulll month, year, hour, minute ans second, e.g. Tuesday, 1 April 2008 18:07:05 |
'v' | writes time hh/mm, e.g. 02:04 |
'V' | writes time h/mm, e.g. 2:04 |
'w' | writes 2 digit hour (24H), e.g. 07 |
'W' | writes hour (24H), e.g. 7 |
'x' | writes 2 digit hour (12H), e.g. 07 |
'X' | writes hour (12H), e.g. 7 |
'y' | writes full month name and year, e.g. October, 71 (locale dependent). |
'Y' | writes full month name and year, e.g. October, 1971 (locale dependent). |
'z' | writes time zone "local" or "UTC". |
'Z' | writes time zone "local" or "UTC". |
|
overridevirtual |
Converts the value of the current xtd::date_time object to its equivalent string representation using the specified format and the formatting conventions of the current culture.
format | A standard or custom date and time format string. |
loc | An std::locale object that contains locale information (see std::locale). |
xtd::format_excpetion | The length of format is 1, and it is not a valid format characters -or- The length si greater than 1. |
Format | |
---|---|
'a' | writes "PM" or "AM" |
'b' | writes 3 digit millisecond, e.G. 012 |
'B' | wrties millisecond, eg 12 |
'c' | writes 7 digit tick, e.G. 0000123 |
'C' | writes tick, e.G. 123 |
'd' | writes date MM/dd/y, e.g. 01/05/42 |
'D' | writes date M/dd/y, e.g. 1/055/42 |
'e' | writes 2 digit second, e.G. 03 |
'B' | writes second, e.G. 3 |
'f' | writes alternative date and time string, e.g. using 平成23年 (year Heisei 23) instead of 2011年 (year 2011) in ja_JP locale. |
'F' | writes standard date and time string, e.g. Sun Oct 17 04:41:13 2010 (locale dependent). |
'g' | writes alternative date and time string, e.g. using 平成23年 (year Heisei 23) instead of 2011年 (year 2011) in ja_JP locale. |
'G' | writes standard date and time string, e.g. Sun Oct 17 04:41:13 2010 (locale dependent). |
'h' | writes abbreviated weekday name, e.g. Fri (locale dependent). |
'H' | writes full weekday name, e.g. Friday (locale dependent). |
'i' | writes 2 digit day, e.g. 05 |
'I' | writes day, e.G. 5 |
'j' | writes abbreviated month name, e.g. Oct (locale dependent) |
'J' | writes full month name, e.g. October (locale dependent). |
'k' | writes 2 digit month, e.g. 01 |
'K' | writes month, e.g. 1 |
'l' | writes 2 digit year, e.g. 71 |
'L' | writes 4 digit year, e.g. 1971 |
'm' | writes year, e.g. 42 |
'M' | writes full month name and day, e.g. October, 5 (locale dependent). |
'n' | writes full weekday name, day, fulll month and year, e.g. Tuesday, 1 April 2008 |
'N' | writes full weekday name, day, fulll month, year, hour, minute ans second, e.g. Tuesday, 1 April 2008 18:07:05 |
'o' | writes day, full month and year, e.g. 5 January 42 |
'O' | writes day, full month and year, e.g. 5 January 42 |
'p' | writes 2 digit minute, e.G. 06 |
'P' | writes minute, e.G. 6 |
's' | writes sortable date/time pattern yyyy-MM-ddThh:mm:ss.ttttttt. e.g. 1971-05-01T21:32:24:42.004567 |
't' | writes time hh/mm/ss, e.g. 02:04:06 |
'T' | writes time h/mm/ss, e.g. 2:04:06 |
'u' | writes sortable short date/time pattern y-MM-dd hh:mm:ss. e.g. 1971-05-01 9:32:24:42 |
'U' | writes full weekday name, day, fulll month, year, hour, minute ans second, e.g. Tuesday, 1 April 2008 18:07:05 |
'v' | writes time hh/mm, e.g. 02:04 |
'V' | writes time h/mm, e.g. 2:04 |
'w' | writes 2 digit hour (24H), e.g. 07 |
'W' | writes hour (24H), e.g. 7 |
'x' | writes 2 digit hour (12H), e.g. 07 |
'X' | writes hour (12H), e.g. 7 |
'y' | writes full month name and year, e.g. October, 71 (locale dependent). |
'Y' | writes full month name and year, e.g. October, 1971 (locale dependent). |
'z' | writes time zone "local" or "UTC". |
'Z' | writes time zone "local" or "UTC". |
Implements xtd::iformatable.
std::time_t xtd::date_time::to_time_t | ( | ) | const |
Converts the value of the current xtd::date_time object to std::time_t.
std::tm xtd::date_time::to_tm | ( | ) | const |
Converts the value of the current xtd::date_time object to std::tm.
date_time xtd::date_time::to_universal_time | ( | ) | const |
Converts the value of the current xtd::date_time object to Coordinated Universal Time (UTC).
Kind | Results |
---|---|
xtd::date_time_kind::utc | No conversion is performed. |
xtd::date_time_kind::local | The current xtd::date_time object is converted to UTC. |
xtd::date_time_kind::unspecified | The current xtd::date_time object is assumed to be a local time, and the conversion is performed as if xtd::date_time::kind were Local. |
|
staticnoexcept |
Gets a xtd::date_time object that is set to the current date and time on this computer, expressed as the local time.
|
staticnoexcept |
Gets the current date.
|
staticnoexcept |
Gets a xtd::date_time object that is set to the current date and time on this computer, expressed as the Coordinated Universal Time (UTC).
|
static |
Returns the number of days in the specified month and year.
year | The year. |
month | The month (one of xtd::month_of_year values). |
xtd::argument_out_of_range_exception | month is less than 1 or greater than 12. -or- year is less than 1 or greater than 9999. |
Returns the number of days in the specified month and year.
year | The year. |
month | The month (a number ranging from 1 to 12). |
xtd::argument_out_of_range_exception | month is less than 1 or greater than 12. -or- year is less than 1 or greater than 9999. |
Deserializes a 64-bit binary value and recreates an original serialized xtd::date_time object.
date_data | A 64-bit signed integer that encodes the xtd::date_time::kind property in a 2-bit field and the xtd::date_time::ticks property in a 62-bit field. |
xtd::argument_exception | date_data is less than xtd::date_time::min_value or greater than xtd::date_time::max_value. |
Converts the specified Windows file time to an equivalent local time.
file_time | A Windows file time expressed in ticks. |
xtd::argument_out_of_range_exception | file_time is less than 0 or represents a time greater than xtd::date_time:max_value. |
Converts the specified Windows file time to an equivalent UTC time.
file_time | A Windows file time expressed in ticks. |
xtd::argument_out_of_range_exception | file_time is less than 0 or represents a time greater than xtd::date_time:max_value. |
Converts the specified xtd::time_span to an equivalent unspecified time.
value | A time interval from the start of the Clock's epoch. |
xtd::argument_out_of_range_exception | value is less than xtd::date_time:min_value or represents a time greater than xtd::date_time:max_value. |
|
static |
Converts the specified xtd::time_span to an equivalent to Coordinated Universal Time (UTC) or local time..
value | A time interval from the start of the Clock's epoch. |
kind | One of the enumeration values that indicates whether ticks specifies a local time, Coordinated Universal Time (UTC), or neither. |
xtd::argument_out_of_range_exception | value is less than xtd::date_time:min_value or represents a time greater than xtd::date_time:max_value. |
|
static |
Converts the specified std::time_t to an equivalent unspecified time.
value | A time interval from the start of the Clock's epoch. |
xtd::argument_out_of_range_exception | value is less than xtd::date_time:min_value or represents a time greater than xtd::date_time:max_value. |
|
static |
Converts the specified std::time_t to an equivalent to Coordinated Universal Time (UTC) or local time.
value | A time interval from the start of the Clock's epoch. |
kind | One of the enumeration values that indicates whether ticks specifies a local time, Coordinated Universal Time (UTC), or neither. |
xtd::argument_out_of_range_exception | value is less than xtd::date_time:min_value or represents a time greater than xtd::date_time:max_value. |
|
static |
Converts the specified std::tm to an equivalent unspecified time.
value | A std::tm struct. |
xtd::argument_out_of_range_exception | value.ttm_year is less than 1 or greater than 9999. -or- tvalue.tm_mon is less than 1 or greater than 12. -or- value.tm_mday is less than 1 or greater than the number of days in month. -or- value.tm_hour is less than 0 or greater than 23. -or- value.tm_min is less than 0 or greater than 59 -or- vale.tm_sec is less than 0 or greater than 59. |
|
static |
Converts the specified std::tm to an equivalent to Coordinated Universal Time (UTC) or local time.
value | A std::tm struct. |
kind | One of the enumeration values that indicates whether ticks specifies a local time, Coordinated Universal Time (UTC), or neither. |
xtd::argument_out_of_range_exception | value.ttm_year is less than 1 or greater than 9999. -or- tvalue.tm_mon is less than 1 or greater than 12. -or- value.tm_mday is less than 1 or greater than the number of days in month. -or- value.tm_hour is less than 0 or greater than 23. -or- value.tm_min is less than 0 or greater than 59 -or- vale.tm_sec is less than 0 or greater than 59. |
|
static |
Returns an indication whether the specified year is a leap year.
year | A 4-digit year. |
xtd::argument_out_of_range_exception | year is less than 1 or greater than 9999. |
|
static |
Converts the string representation of a date and time to its xtd::date_time equivalent by using the conventions of the current culture.
s | A string that contains a date and time to convert. See The string to parse for more information. |
xtd::format_exception | s does not contain a valid string representation of a date and time. |
|
static |
Creates a new xtd::date_time object that has the same number of ticks as the specified xtd::date_time, but is designated as either local time, Coordinated Universal Time (UTC), or neither, as indicated by the specified xtd::date_time_kind value.
value | A date and time. |
kind | One of the enumeration values that indicates whether the new object represents local time, UTC, or neither. |
|
static |
Returns a xtd::string that represents the current xtd::date_time.
format | Format-control String. |
value | The xtd::date_time object to format. |
Format | |
---|---|
%a | writes abbreviated weekday name, e.g. Fri (locale dependent). |
%A | writes full weekday name, e.g. Friday (locale dependent). |
%b | writes abbreviated month name, e.g. Oct (locale dependent) |
%B | writes full month name, e.g. October (locale dependent). |
%c | writes standard date and time string, e.g. Sun Oct 17 04:41:13 2010 (locale dependent). |
%C | writes first 2 digits of year as a decimal number (range [00,99]). |
%d | writes day of the month as a decimal number (range [01,31]). |
%D | equivalent to "%m/%d/%y". |
%e | writes day of the month as a decimal number (range [1,31]). |
%Ec | writes alternative date and time string, e.g. using 平成23年 (year Heisei 23) instead of 2011年 (year 2011) in ja_JP locale. |
%EC | Writes name of the base year (period) in the locale's alternative representation, e.g. 平成 (Heisei era) in ja_JP |
%Ex | writes alternative date representation, e.g. using 平成23年 (year Heisei 23) instead of 2011年 (year 2011) in ja_JP locale. |
%EX | writes alternative time representation (locale dependent). |
%Ey | writes year as offset from locale's alternative calendar period EC. |
%EY | writes year in the alternative representation, e.g.平成23年 (year Heisei 23) instead of 2011年 (year 2011) in ja_JP locale. |
%F | equivalent to "%Y-%m-%d" (the ISO 8601 date format). |
%g | writes last 2 digits of ISO 8601 week-based year, i.e. the year that contains the specified week (range [00,99]). |
%G | writes ISO 8601 week-based year, i.e. the year that contains the specified week. |
%h | synonym of b. |
%H | writes hour as a decimal number, 24 hour clock (range [00-23]). |
%I | writes hour as a decimal number, 12 hour clock (range [01,12]). |
%j | writes day of the year as a decimal number (range [001,366]). |
%m | writes month as a decimal number (range [01,12]). |
%M | writes minute as a decimal number (range [00,59]). |
%Od | writes zero-based day of the month using the alternative numeric system, e.g 二十七 instead of 27 in ja_JP locale. |
%Oe | writes one-based day of the month using the alternative numeric system, e.g. 二十七 instead of 27 in ja_JP locale. |
%OH | writes hour from 24-hour clock using the alternative numeric system, e.g. 十八 instead of 18 in ja_JP locale. |
%OI | writes hour from 12-hour clock using the alternative numeric system, e.g. 六 instead of 06 in ja_JP locale. |
%Om | writes month using the alternative numeric system, e.g. 十二 instead of 12 in ja_JP locale. |
%OM | writes minute using the alternative numeric system, e.g. 二十五 instead of 25 in ja_JP locale. |
%OS | writes second using the alternative numeric system, e.g. 二十四 instead of 24 in ja_JP locale. |
%Ou | writes weekday, where Monday is 1, using the alternative numeric system, e.g. 二 instead of 2 in ja_JP locale. |
%OU | writes week of the year, as by U, using the alternative numeric system, e.g. 五十二 instead of 52 in ja_JP locale. |
%OV | writes week of the year, as by V, using the alternative numeric system, e.g. 五十二 instead of 52 in ja_JP locale. |
%Ow | writes weekday, where Sunday is 0, using the alternative numeric system, e.g. 二 instead of 2 in ja_JP locale. |
%OW | writes week of the year, as by W, using the alternative numeric system, e.g. 五十二 instead of 52 in ja_JP locale. |
%Oy | writes last 2 digits of year using the alternative numeric system, e.g. 十一 instead of 11 in ja_JP locale. |
%p | writes localized a.m. or p.m. (locale dependent). |
%r | writes localized 12-hour clock time (locale dependent). |
%R | equivalent to "%H:%M". |
%S | writes second as a decimal number (range [00,60]). |
%T | equivalent to "%H:%M:%S" (the ISO 8601 time format) |
%u | writes weekday as a decimal number, where Monday is 1 (ISO 8601 format) (range [1-7]). |
%U | writes week of the year as a decimal number (Sunday is the first day of the week) (range [00,53]). |
%V | writes ISO 8601 week of the year (range [01,53]). |
%w | writes weekday as a decimal number, where Sunday is 0 (range [0-6]). |
%W | writes week of the year as a decimal number (Monday is the first day of the week) (range [00,53]). |
%x | writes localized date representation (locale dependent). |
%X | writes localized time representation, e.g. 18:40:20 or 6:40:20 PM (locale dependent). |
%y | writes last 2 digits of year as a decimal number (range [00,99]). |
%Y | writes year as a decimal number, e.g. 2017. |
%z | writes offset from UTC in the ISO 8601 format (e.g. -0430), or no characters if the time zone information is not available. |
%Z | writes locale-dependent time zone name or abbreviation, or no characters if the time zone information is not available. |
%% | writes literal %. The full conversion specification must be %%. |
%n | writes newline character. |
%t | writes horizontal tab character. |
Converts the specified string representation of a date and time to its xtd::date_time equivalent and returns a value that indicates whether the conversion succeeded.
s | A string containing a date and time to convert. |
result | When this method returns, contains the xtd::date_time value equivalent to the date and time contained in s, if the conversion succeeded, or xtd::date_time::min_value if the conversion failed. The conversion fails if the s parameter is an empty string (""), or does not contain a valid string representation of a date and time. |
|
virtualnoexcept |
Determines whether the specified object is equal to the current object.
obj | The object to compare with the current object. |
Reimplemented from xtd::object.
|
inlinestaticnoexcept |
Determines whether the specified object instances are considered equal.
object_a | The first object to compare. |
object_b | The second object to compare. |
|
static |
Represents the largest possible value of xtd::date_time. This field is read-only.
|
static |
Represents the smallest possible value of xtd::date_time. This field is read-only.