Struct DateTime
Represents date and time.
Assembly: FlaxEngine.dll
File: Engine/Core/Types/DateTime.h
Syntax
public struct DateTime
Constructors
DateTime()
Empty constructor.
Declaration
public DateTime()
DateTime(int32 year, int32 month, int32 day, int32 hour = 0, int32 minute = 0, int32 second = 0, int32 millisecond = 0)
Initializes a new instance of the DateTime struct.
Declaration
public DateTime(int32 year, int32 month, int32 day, int32 hour = 0, int32 minute = 0, int32 second = 0, int32 millisecond = 0)
Parameters
int32
year
The year. |
int32
month
The month. |
int32
day
The day. |
int32
hour
The hour. |
int32
minute
The minute. |
int32
second
The second. |
int32
millisecond
The millisecond. |
DateTime(int64 ticks)
Initializes a new instance of the DateTime struct.
Declaration
public DateTime(int64 ticks)
Parameters
int64
ticks
The ticks representing the date and time. |
Fields
Ticks
Ticks in 100 nanoseconds resolution since January 1, 0001 A.D.
Declaration
public int64 Ticks
Field Value
int64
|
Methods
DaysInMonth(int32 year, int32 month)
Gets the number of days in the year and month.
Declaration
public static int32 DaysInMonth(int32 year, int32 month)
Parameters
int32
year
The year. |
int32
month
The month. |
Returns
int32
The number of days |
DaysInYear(int32 year)
Gets the number of days in the given year.
Declaration
public static int32 DaysInYear(int32 year)
Parameters
int32
year
The year. |
Returns
int32
The number of days. |
GetDate()
Gets the date part of this date. The time part is truncated and becomes 00:00:00.000.
Declaration
public DateTime GetDate() const
Returns
DateTime
|
GetDate(int32& year, int32& month, int32& day)
Gets the date components of this date.
Declaration
public void GetDate(int32& year, int32& month, int32& day) const
Parameters
int32
year
The year. |
int32
month
The month (1-12). |
int32
day
The day (1-31). |
GetDay()
Gets this date's day part (1 to 31).
Declaration
public int32 GetDay() const
Returns
int32
|
GetDayOfWeek()
Calculates this date's day of the week (Sunday - Saturday).
Declaration
public DayOfWeek GetDayOfWeek() const
Returns
DayOfWeek
|
GetDayOfYear()
Gets this date's day of the year.
Declaration
public int32 GetDayOfYear() const
Returns
int32
|
GetHour()
Gets this date's hour part in 24-hour clock format (0 to 23).
Declaration
public int32 GetHour() const
Returns
int32
|
GetHour12()
Gets this date's hour part in 12-hour clock format (1 to 12).
Declaration
public int32 GetHour12() const
Returns
int32
|
GetJulianDay()
Gets the Julian Day for this date.
The Julian Day is the number of days since the inception of the Julian calendar at noon on Monday, January 1, 4713 B.C.E. The minimum Julian Day that can be represented in DateTime is 1721425.5, which corresponds to Monday, January 1, 0001 in the Gregorian calendar.
Declaration
public double GetJulianDay() const
Returns
double
|
GetMillisecond()
Gets this date's millisecond part (0 to 999).
Declaration
public int32 GetMillisecond() const
Returns
int32
|
GetMinute()
Gets this date's minute part (0 to 59).
Declaration
public int32 GetMinute() const
Returns
int32
|
GetModifiedJulianDay()
Gets the Modified Julian day.
The Modified Julian Day is calculated by subtracting 2400000.5, which corresponds to midnight UTC on November 17, 1858 in the Gregorian calendar.
Declaration
public double GetModifiedJulianDay() const
Returns
double
|
GetMonth()
Gets this date's the month part (1 to 12).
Declaration
public int32 GetMonth() const
Returns
int32
|
GetMonthOfYear()
Gets the date's month of the year (January to December).
Declaration
public MonthOfYear GetMonthOfYear() const
Returns
MonthOfYear
|
GetSecond()
Gets this date's second part.
Declaration
public int32 GetSecond() const
Returns
int32
|
GetTicks()
Gets this date's representation as number of ticks since midnight, January 1, 0001.
Declaration
public int64 GetTicks() const
Returns
int64
|
GetTimeOfDay()
Gets the time elapsed since midnight of this date.
Declaration
public TimeSpan GetTimeOfDay() const
Returns
TimeSpan
|
GetYear()
Gets this date's year part.
Declaration
public int32 GetYear() const
Returns
int32
|
IsLeapYear(int32 year)
Determines whether the specified year is a leap year.
A leap year is a year containing one additional day in order to keep the calendar synchronized with the astronomical year.
Declaration
public static bool IsLeapYear(int32 year)
Parameters
int32
year
The year. |
Returns
bool
|
MaxValue()
Returns the maximum date value.
The maximum date value is December 31, 9999, 23:59:59.9999999.
Declaration
public static DateTime MaxValue()
Returns
DateTime
The maximum valid date. |
MinValue()
Returns the minimum date value.
The minimum date value is January 1, 0001, 00:00:00.0.
Declaration
public static DateTime MinValue()
Returns
DateTime
The minimum valid date. |
Now()
Gets the local date and time on this computer.
This method takes into account the local computer's time zone and daylight saving settings. For time zone independent time comparisons, and when comparing times between different computers, use NowUTC() instead.
Declaration
public static DateTime Now()
Returns
DateTime
The current date and time. |
NowUTC()
Gets the UTC date and time on this computer.
This method returns the Coordinated Universal Time (UTC), which does not take the local computer's time zone and daylight savings settings into account. It should be used when comparing dates and times that should be independent of the user's locale. To get the date and time in the current locale, use Now() instead.
Declaration
public static DateTime NowUTC()
Returns
DateTime
The current date and time. |
operator!=(const DateTime& other)
Declaration
public bool operator!=(const DateTime& other) const
Parameters
DateTime
other
|
Returns
bool
|
operator-(const DateTime& other)
Declaration
public TimeSpan operator-(const DateTime& other) const
Parameters
DateTime
other
|
Returns
TimeSpan
|
operator-(const TimeSpan& other)
Declaration
public DateTime operator-(const TimeSpan& other) const
Parameters
TimeSpan
other
|
Returns
DateTime
|
operator+(const TimeSpan& other)
Declaration
public DateTime operator+(const TimeSpan& other) const
Parameters
TimeSpan
other
|
Returns
DateTime
|
operator+=(const TimeSpan& other)
Declaration
public DateTime operator+=(const TimeSpan& other)
Parameters
TimeSpan
other
|
Returns
DateTime
|
operator<(const DateTime& other)
Declaration
public bool operator<(const DateTime& other) const
Parameters
DateTime
other
|
Returns
bool
|
operator<=(const DateTime& other)
Declaration
public bool operator<=(const DateTime& other) const
Parameters
DateTime
other
|
Returns
bool
|
operator-=(const TimeSpan& other)
Declaration
public DateTime operator-=(const TimeSpan& other)
Parameters
TimeSpan
other
|
Returns
DateTime
|
operator==(const DateTime& other)
Declaration
public bool operator==(const DateTime& other) const
Parameters
DateTime
other
|
Returns
bool
|
operator>(const DateTime& other)
Declaration
public bool operator>(const DateTime& other) const
Parameters
DateTime
other
|
Returns
bool
|
operator>=(const DateTime& other)
Declaration
public bool operator>=(const DateTime& other) const
Parameters
DateTime
other
|
Returns
bool
|
ToFileNameString()
Gets the string that is valid for filename.
Declaration
public String ToFileNameString() const
Returns
String
|
ToString()
Validate(int32 year, int32 month, int32 day, int32 hour, int32 minute, int32 second, int32 millisecond)
Validates the given components of a date and time value.
Declaration
public static bool Validate(int32 year, int32 month, int32 day, int32 hour, int32 minute, int32 second, int32 millisecond)
Parameters
int32
year
The year (1 - 9999). |
int32
month
The month (1 - 12). |
int32
day
The day (1 - DaysInMonth(Month)). |
int32
hour
The hour (0 - 23). |
int32
minute
The minute (0 - 59). |
int32
second
The second (0 - 59). |
int32
millisecond
The millisecond (0 - 999). |
Returns
bool
True if all the components are valid, false otherwise. |