System::DateTime class
Contents
[
Hide
]DateTime class
Represents a specific date and time value on the time continuum. This type should be allocated on stack and passed to functions by value or by reference. Never use System::SmartPtr class to manage objects of this type.
class DateTime
Methods
Method | Description |
---|---|
Add(TimeSpan) const | Returns a new instance of DateTime class that represents a date and time value that results from addition of the specified time span to the date and time value represented by the current object. |
AddDays(double) const | Returns a new instance of the DateTime class representing the date and time value which is the sum of the value represented by the current object and the specified number of days. |
AddHours(double) const | Returns a new instance of the DateTime class representing the date and time value which is the sum of the value represented by the current object and the specified number of hours. |
AddMilliseconds(double) const | Returns a new instance of the DateTime class representing the date and time value which is the sum of the value represented by the current object and the specified number of milliseconds. |
AddMinutes(double) const | Returns a new instance of the DateTime class representing the date and time value which is the sum of the value represented by the current object and the specified number of minutes. |
AddMonths(int) const | Returns a new instance of the DateTime class representing the date and time value which is the sum of the value represented by the current object and the specified number of months. |
AddSeconds(double) const | Returns a new instance of the DateTime class representing the date and time value which is the sum of the value represented by the current object and the specified number of seconds. |
AddTicks(int64_t) const | Returns a new instance of the DateTime class representing the date and time value which is the sum of the value represented by the current object and the specified number of 100-nanosecond intervals. |
AddYears(int) const | Returns a new instance of the DateTime class representing the date and time value equal to that represented by the current object with the year component increased by the specified number. |
static Compare(DateTime, DateTime) | Compares two values represented by the specified instances of DateTime class and returns the value indicating values’ relative positions on the time line. |
CompareTo(DateTime) const | Compares two date and time values represented by the current object and the specified instance of DateTime class and returns the value indicating values’ relative positions on the time line. |
DateTime() | Constructs an instance that represents the smallest possible date and time value equal to MinValue. |
DateTime(int, int, int) | Constructs an instance that represents a date and time value specified as a particular year, month and day. |
DateTime(int, int, int, const SharedPtr<Globalization::Calendar>&) | Constructs an instance that represents a date and time value specified as a particular year, month and day in the specified calendar. |
DateTime(int, int, int, int, int, int) | Constructs an instance that represents a date and time value specified as a particular year, month, day, hour, minute and second. |
DateTime(int, int, int, int, int, int, DateTimeKind) | Constructs an instance that represents a date and time value specified as a particular year, month, day, hour, minute and second. |
DateTime(int, int, int, int, int, int, const SharedPtr<Globalization::Calendar>&) | Constructs an instance that represents a date and time value specified as a particular year, month, day, hour, minute and second in the specified calendar. |
DateTime(int, int, int, int, int, int, int, DateTimeKind) | Constructs an instance that represents a date and time value specified as a particular year, month, day, hour, minute, second and millisecond. |
DateTime(int, int, int, int, int, int, int, const SharedPtr<Globalization::Calendar>&, DateTimeKind) | Constructs an instance that represents a date and time value specified as a particular year, month, day, hour, minute, second and millisecond in the specified calendar. |
DateTime(int64_t, DateTimeKind) | Construct an instance that represents a date and time value specified as a number of ticks. |
DateTime(int64_t, DateTimeKind, bool) | Construct an instance that represents a date and time value specified as a number of ticks. FOR INTERNAL USE. |
DateTime(const DateTime&) | Copy-constructs an instance. |
static DaysInMonth(int, int) | Returns the number of days in the specified month of the specified year. |
static Equals(DateTime, DateTime) | Determines if the specified instances of DateTime class represent the same date and time value. |
Equals(DateTime) const | Determines if the specified instance of DateTime class represent the same date and time value as the current object. |
static FromBinary(int64_t) | Deserializes the date time value from the specified unsigned 64-bit integer and sets the new instance of DateTime class to that value. |
static FromFileTime(int64_t) | Converts the specified File time to an instance of DateTime class representing the same date and time value as local time. |
static FromFileTimeUtc(int64_t) | Converts the specified File time to an instance of DateTime class representing the same date and time value as UTC time. |
static FromOADate(double) | Returns an instance of DateTime class representing the date and time value equivalent to the specified OLE Automation Date. |
static FromUnixTime(time_t) | Converts the specified Unix time value to an instance of DateTime class. FOR INTERNAL USE. |
get_Date() const | Returns a new instance of DateTime class that represents the date portion of the date and time represented by the current object with each component of the time portion set to 0. |
get_Day() const | Returns the ordinal number of the day in the month represented by the current object. |
get_DayOfWeek() const | Returns a value representing a day of week that is represented by the current object. |
get_DayOfYear() const | Returns the ordinal number of the day in the year represented by the current object. |
get_Hour() const | Returns the hour component of the date and time value represented by the current object. |
get_Kind() const | Returns the value representing if the date and time represented by the current object is a local or UTC date and time or neither. |
get_Millisecond() const | Returns the millisecond component of the date and time value represented by the current object. |
get_Minute() const | Returns the minute component of the date and time value represented by the current object. |
get_Month() const | Returns the ordinal number of the month in the year represented by the current object. |
static get_Now() | Returns an instance of DateTime class that represents the current time as local time. |
get_Second() const | Returns the second component of the date and time value represented by the current object. |
get_Ticks() const | Returns a number of 100-nanosecond intervals passed since 0:00:00 UTC, January 1, 0001, in the Gregorian calendar until the date and time represented by the current object. |
get_TimeOfDay() const | Returns the value that represents the time interval from the beginning of the day represented by the current object till the date and time value represented by the current object. |
static get_Today() | Returns an instance of DateTime class that represents the current date with each component of time portion of the value represented by the object set to 0. |
static get_UtcNow() | Returns an instance of DateTime class that represents the current time as UTC. |
get_Year() const | Returns the year represented by the current object. |
GetDateComponents(int&, int&, int&) const | Gets date parts. FOR INTERNAL USE. |
GetDateTimeFormats() const | Returns array of strings where each element is the string representation of the current object formatted with one of the standard date and time format specifiers. |
GetDateTimeFormats(char_t) const | Returns array of strings where each element is the string representation of the current object formatted with the specified standard date and time format specifier. |
GetDateTimeFormats(const SharedPtr<IFormatProvider>&) const | Returns array of strings where each element is the string representation of the current object formatted with one of the standard date and time format specifiers and the specified format provider. |
GetDateTimeFormats(char_t, const SharedPtr<IFormatProvider>&) const | Returns array of strings where each element is the string representation of the current object formatted with the specified standard date and time format specifier and format provider. |
GetHashCode() const | Returns a hash code for the current object. |
IsDaylightSavingTime() const | Determines if the date and time value represented by the current object falls in the range of daylight saving time for the current time zone. |
static IsLeapYear(int) | Determines of the specified year is a leap year. |
IsNull() const | |
operator!=(DateTime) const | Determines if the current object and the specified DateTime object represent distinct date and time values. |
operator!=(std::nullptr_t) const | |
operator+(TimeSpan) const | Returns a new instance of DateTime class that represents the date and time value that is the sum of the value represented by the current object and the specified time span. |
operator+=(TimeSpan) | Sets the current object to the date and time value that is the sum of the value represented by the current object and the specified time span. |
operator-(TimeSpan) const | Returns a new instance of the DateTime class representing the date and time value which is the result of subtraction of the specified time span from the value represented by the current object. |
operator-(DateTime) const | Returns an instance of TimeSpan class that represents the time interval between the date and time values represented by the current and the specified objects. |
operator-=(TimeSpan) | Sets the current object to the date and time value that is the result of subtraction of the specified time span from the date and time value represented by the current object. |
operator<(DateTime) const | Determines if the current object represents the date and time value that is earlier than the value represented by the specified DateTime object. |
operator<(std::nullptr_t) const | |
operator<=(DateTime) const | Determines if the current object represents the date and time value that is earlier than or the same as the value represented by the specified DateTime object. |
operator<=(std::nullptr_t) const | |
operator=(const DateTime&) | Assigns the value represented by the specified DateTime instance to the current object. |
operator==(DateTime) const | Determines if the current object and the specified DateTime object represent the same date and time value. |
operator==(std::nullptr_t) const | |
operator>(DateTime) const | Determines if the current object represents the date and time value that is later than the value represented by the specified DateTime object. |
operator>(std::nullptr_t) const | |
operator>=(DateTime) const | Determines if the current object represents the date and time value that is later than or the same as the value represented by the specified DateTime object. |
operator>=(std::nullptr_t) const | |
static Parse(const String&) | Converts the specified string representation of a date and time value to the equivalent DateTime object. |
static Parse(const String&, const SharedPtr<IFormatProvider>&, Globalization::DateTimeStyles) | Converts the specified string representation of a date and time value to the equivalent DateTime object using culture-specific format information. |
static Parse(const String&, const SharedPtr<Globalization::CultureInfo>&, Globalization::DateTimeStyles) | |
static Parse(const String&, const SharedPtr<Globalization::DateTimeFormatInfo>&, Globalization::DateTimeStyles) | |
static Parse(const String&, std::nullptr_t, Globalization::DateTimeStyles) | |
static ParseExact(const String&, const String&, const SharedPtr<IFormatProvider>&, Globalization::DateTimeStyles) | Converts the specified string representation of a date and time value to the equivalent DateTime object using the specified format and culture-specific format information. The format of the string representation must match the specified format exactly. Throws an exception if the conversion fails. |
static ParseExact(const String&, const String&, const SharedPtr<Globalization::CultureInfo>&, Globalization::DateTimeStyles) | |
static ParseExact(const String&, const String&, const SharedPtr<Globalization::DateTimeFormatInfo>&, Globalization::DateTimeStyles) | |
static ParseExact(const String&, const String&, std::nullptr_t, Globalization::DateTimeStyles) | |
static ParseExact(const String&, const ArrayPtr<String>&, const SharedPtr<IFormatProvider>&, Globalization::DateTimeStyles) | Converts the specified string representation of a date and time value to the equivalent DateTime object using the specified formats, culture-specific format information and style. The format of the string representation must match one or more of the specified formats exactly. Throws an exception if the conversion fails. |
static ParseExact(const String&, const ArrayPtr<String>&, const SharedPtr<Globalization::CultureInfo>&, Globalization::DateTimeStyles) | |
static ParseExact(const String&, const ArrayPtr<String>&, const SharedPtr<Globalization::DateTimeFormatInfo>&, Globalization::DateTimeStyles) | |
static ParseExact(const String&, const ArrayPtr<String>&, std::nullptr_t, Globalization::DateTimeStyles) | |
static SpecifyKind(DateTime, DateTimeKind) | Constructs a new DateTime object that represents the same number of ticks as the specified DateTime object and represents local time, UTC time or neither as specified by the argument kind. |
Subtract(TimeSpan) const | Returns a new instance of the DateTime class representing the date and time value which is the result of subtraction of the specified time span from the value represented by the current object. |
Subtract(DateTime) const | Returns an instance of TimeSpan class representing the time interval between the date and time values represented by the current and the specified objects. |
ToBinary() const | Serializes the current object. |
ToFileTime() const | Returns a value that represents the date and time value represented by the current object as File time. |
ToFileTimeUtc() const | Converts the date and time value represented by the current object to File time UTC. |
ToLocalTime() const | Returns a new instance of DateTime class that represents the date and time value represented by the current object as local time. |
ToLongDateString() const | Returns a string that contains the long date string representation of the current object. |
ToLongTimeString() const | Returns a string that contains the long time string representation of the current object. |
ToOADate() const | Returns the date and time value represented by the current object as OLE Automation Date. |
ToShortDateString() const | Returns a string that contains the short date string representation of the current object. |
ToShortTimeString() const | Returns a string that contains the short time string representation of the current object. |
ToString() const | Returns the string representation of the date and time value represented by the current object using the formatting conventions defined by the current culture. |
ToString(const String&) const | Returns a string representation of the date and time value represented by the current object using the specified format and formatting conventions defined by the current culture. |
ToString(const SharedPtr<IFormatProvider>&) const | Returns a string representation of the date and time value represented by the current object using the specified format information. |
ToString(const SharedPtr<Globalization::CultureInfo>&) const | |
ToString(const SharedPtr<Globalization::DateTimeFormatInfo>&) const | |
ToString(std::nullptr_t) const | |
ToString(const String&, const SharedPtr<IFormatProvider>&) const | Returns a string representation of the date and time value represented by the current object using the specified format information. |
ToString(const String&, const SharedPtr<Globalization::CultureInfo>&) const | |
ToString(const String&, const SharedPtr<Globalization::DateTimeFormatInfo>&) const | |
ToString(const String&, std::nullptr_t) const | |
ToUniversalTime() const | Returns a new instance of DateTime class that represents the date and time value represented by the current object as UTC. |
ToUnixTime() const | Returns a value that represents the date and time value represented by the current object as Unix time. FOR INTERNAL USE. |
static TryParse(const String&, DateTime&) | Converts the specified string representation of a date and time value to the equivalent DateTime object. |
static TryParse(const String&, const SharedPtr<IFormatProvider>&, Globalization::DateTimeStyles, DateTime&) | Converts the specified string representation of a date and time value to the equivalent DateTime object using the specified culture-specific format information and style. |
static TryParse(const String&, const SharedPtr<Globalization::CultureInfo>&, Globalization::DateTimeStyles, DateTime&) | |
static TryParse(const String&, const SharedPtr<Globalization::DateTimeFormatInfo>&, Globalization::DateTimeStyles, DateTime&) | |
static TryParse(const String&, std::nullptr_t, Globalization::DateTimeStyles, DateTime&) | |
static TryParseExact(const String&, const String&, const SharedPtr<IFormatProvider>&, Globalization::DateTimeStyles, DateTime&) | Converts the specified string representation of a date and time value to the equivalent DateTime object using the specified format, culture-specific format information and style. The format of the string representation must match the specified format exactly. |
static TryParseExact(const String&, const String&, const SharedPtr<Globalization::CultureInfo>&, Globalization::DateTimeStyles, DateTime&) | |
static TryParseExact(const String&, const String&, const SharedPtr<Globalization::DateTimeFormatInfo>&, Globalization::DateTimeStyles, DateTime&) | |
static TryParseExact(const String&, const String&, std::nullptr_t, Globalization::DateTimeStyles, DateTime&) | |
static TryParseExact(const String&, const ArrayPtr<String>&, const SharedPtr<IFormatProvider>&, Globalization::DateTimeStyles, DateTime&) | Converts the specified string representation of a date and time value to the equivalent DateTime object using the specified formats, culture-specific format information and style. The format of the string representation must match one or more of the specified formats exactly. |
static TryParseExact(const String&, const ArrayPtr<String>&, const SharedPtr<Globalization::CultureInfo>&, Globalization::DateTimeStyles, DateTime&) | |
static TryParseExact(const String&, const ArrayPtr<String>&, const SharedPtr<Globalization::DateTimeFormatInfo>&, Globalization::DateTimeStyles, DateTime&) | |
static TryParseExact(const String&, const ArrayPtr<String>&, std::nullptr_t, Globalization::DateTimeStyles, DateTime&) | |
static Type() | Returns a TypeInfo object that contains information about this class. |
Fields
Field | Description |
---|---|
static constexpr MaxTicks | The number of 100-nanosecond in the time interval between the minimal possible and maximal possible DateTime value. |
static MaxValue | An instance of DateTime class that represents the maximal possible date and time value. |
static constexpr MinTicks | The minimal number of ticks that an instance of DateTime class can represent. |
static MinValue | An instance of DateTime class that represents the minimal possible date and time value. |
static constexpr TicksPerDay | The number of ticks in a day. |
static constexpr TicksPerHour | The number of ticks in a hour. |
static constexpr TicksPerMicrosecond | The number of ticks in a microsecond. |
static constexpr TicksPerMillisecond | The number of ticks in a millisecond. |
static constexpr TicksPerMinute | The number of ticks in a minute. |
static constexpr TicksPerSecond | The number of ticks in a second. |
static UnixEpoch | An instance of DateTime class that represents the Unix epoch start (1970.01.01 00:00:00). |
Remarks
#include "system/console.h"
#include "system/date_time.h"
int main()
{
using namespace System;
// Create the 'DateTime' class instance.
DateTime dateTime{1990, 10, 30};
// Print the instance in the multiple formats.
Console::WriteLine(dateTime.ToShortDateString());
Console::WriteLine(dateTime.ToShortTimeString());
Console::WriteLine(dateTime.ToString());
return 0;
}
/*
This code example produces the following output:
30.10.1990
0:00
30.10.1990 0:00:00
*/
See Also
- Namespace System
- Library Aspose.TeX for C++