struct · System
DateTime
public struct System.DateTime : System.IHashable<System.DateTime>, System.IComparable<System.DateTime>
A moment on the calendar, from 0001-01-01 to 9999-12-31, to 100 ns, and whose clock it reads (Kind).
date + span, date - span, a - b (a TimeSpan) and the comparisons work on it; as text it is
MM/dd/yyyy HH:mm:ss, and ToString("o") gives the round-trip form.
- Tipo
- struct
- Espacio de nombres
- System
- Ensamblado
- System.Core
- Acceso
- public
- Archivo fuente
Time.ant
Herencia
- Interfaces
-
IHashable<TSelf>IComparable<TSelf>
Constructores
Propiedades
static property MinValue: System.DateTime
#
static property MaxValue: System.DateTime
#
static property UnixEpoch: System.DateTime
#
1970-01-01 00:00:00 UTC.
static property UtcNow: System.DateTime
#
Now: in UTC, in the local time zone, and today's date (local, at midnight).
static property Now: System.DateTime
#
static property Today: System.DateTime
#
property Kind: System.DateTimeKind
#
property DayOfWeek: System.DayOfWeek
#
1 for January 1st.
property Date: System.DateTime
#
The date at midnight (same kind), and the time since midnight.
property TimeOfDay: System.TimeSpan
#
Métodos
static method SpecifyKind(value: System.DateTime, kind: System.DateTimeKind) -> System.DateTime
#
The same moment with another kind (the clock reading is not changed).
method Add(span: System.TimeSpan) -> System.DateTime
#
method AddTicks(value: i64) -> System.DateTime
#
method AddDays(value: f64) -> System.DateTime
#
method AddHours(value: f64) -> System.DateTime
#
method AddMinutes(value: f64) -> System.DateTime
#
method AddSeconds(value: f64) -> System.DateTime
#
method AddMilliseconds(value: f64) -> System.DateTime
#
method AddMicroseconds(value: f64) -> System.DateTime
#
method AddMonths(months: i32) -> System.DateTime
#
months months later: the same day, or the month's last day when it is shorter.
method AddYears(years: i32) -> System.DateTime
#
method Subtract(other: System.DateTime) -> System.TimeSpan
#
The time from other to this moment, and this moment span earlier.
method Subtract(span: System.TimeSpan) -> System.DateTime
#
method Equals(other: System.DateTime) -> bool
#
The same moment (the kind is not compared).
method CompareTo(other: System.DateTime) -> i32
#
static method Compare(a: System.DateTime, b: System.DateTime) -> i32
#
method ToUniversalTime() -> System.DateTime
#
The moment on UTC's clock and on the local time zone's (Unspecified counts as the other one).
method ToLocalTime() -> System.DateTime
#
Seconds and milliseconds since 1970-01-01 UTC (Unspecified counts as UTC), and the UTC moment of a count of them.
static method FromUnixTimeSeconds(seconds: i64) -> System.DateTime
#
static method FromUnixTimeMilliseconds(milliseconds: i64) -> System.DateTime
#
method ToString() -> System.String<u8>
#
MM/dd/yyyy HH:mm:ss.
method ToString(format: System.String<u8>) -> System.String<u8>
#
As text by a format: a standard one (d, D, f, F, g, G, M, o, R, s, t, T, u, U, Y) or a custom one of yyyy, yy, MMMM, MMM, MM, M, dddd, ddd, dd, d, HH, H, hh, h, mm, m, ss, s, f…, F…, tt, t, K, zzz, zz, z, 'text', "text" and \x.
static method Parse(text: System.String<u8>) -> System.DateTime
#
The moment text writes: ISO 8601 (2024-05-01, 2024-05-01T13:45:30.5Z, …+02:00), the invariant
culture's 05/01/2024 1:45 PM, Wed, 01 May 2024 13:45:30 GMT, 1 May 2024, May 1, 2024, or a time
alone (today); a FormatError when it writes none.
static method Parse(text: System.String<u8>, styles: System.DateTimeStyles) -> System.DateTime
#
static method ParseExact(text: System.String<u8>, format: System.String<u8>) -> System.DateTime
#
The moment text writes in exactly format (a standard or custom format, as ToString takes).
static method ParseExact(text: System.String<u8>, format: System.String<u8>, styles: System.DateTimeStyles) -> System.DateTime
#
static method TryParse(text: System.String<u8>) -> System.DateTime?
#
The moment, or null when text writes none.
static method TryParse(text: System.String<u8>, styles: System.DateTimeStyles) -> System.DateTime?
#
static method TryParseExact(text: System.String<u8>, format: System.String<u8>) -> System.DateTime?
#
static method TryParseExact(text: System.String<u8>, format: System.String<u8>, styles: System.DateTimeStyles) -> System.DateTime?
#
The bits (ticks and kind), and a DateTime from them.
static method FromBinary(bits: i64) -> System.DateTime
#
Operadores y conversiones
static operator $op_Add(d: System.DateTime, span: System.TimeSpan) -> System.DateTime
#
static operator $op_Subtract(d: System.DateTime, span: System.TimeSpan) -> System.DateTime
#
static operator $op_Subtract(a: System.DateTime, b: System.DateTime) -> System.TimeSpan
#
static operator $op_Equal(a: System.DateTime, b: System.DateTime) -> bool
#
static operator $op_NotEqual(a: System.DateTime, b: System.DateTime) -> bool
#
static operator $op_Less(a: System.DateTime, b: System.DateTime) -> bool
#
static operator $op_LessEqual(a: System.DateTime, b: System.DateTime) -> bool
#
static operator $op_Greater(a: System.DateTime, b: System.DateTime) -> bool
#
static operator $op_GreaterEqual(a: System.DateTime, b: System.DateTime) -> bool
#
Miembros privados e internos (7)
Throws an ArgumentOutOfRangeError: the message is made here, so the fast paths that may throw allocate nothing.
static method Of(data: u64) -> System.DateTime
#
A DateTime from its bits (ticks already checked).
The ticks of a date (checked), as .NET's DateToTicks.
method Moved(value: i64) -> System.DateTime
#
This moment value ticks later (an ArgumentOutOfRangeError past the calendar's ends).
method AddUnits(value: f64, most: i64, scale: i64) -> System.DateTime
#
value units of scale ticks later: whole units exactly, the fraction rounded toward zero.
Código fuente
DateTime en Larva HIR, descompilado a partir de su Larva HIR.
// A moment on the calendar, from 0001-01-01 to 9999-12-31, to 100 ns, and whose clock it reads (Kind).
// `date + span`, `date - span`, `a - b` (a TimeSpan) and the comparisons work on it; as text it is
// `MM/dd/yyyy HH:mm:ss`, and ToString("o") gives the round-trip form.
public struct System.DateTime : System.IHashable<System.DateTime>, System.IComparable<System.DateTime>
{
field data: u64
// Throws an ArgumentOutOfRangeError: the message is made here, so the fast paths that may throw allocate nothing.
static method OutOfRange(which: i32) -> void
// A DateTime from its bits (ticks already checked).
static method Of(data: u64) -> System.DateTime
// The ticks of a date (checked), as .NET's DateToTicks.
static method DateTicks(year: i32, month: i32, day: i32) -> i64
static method TimeTicks(hour: i32, minute: i32, second: i32) -> i64
// This moment `value` ticks later (an ArgumentOutOfRangeError past the calendar's ends).
method Moved(value: i64) -> System.DateTime
// `value` units of `scale` ticks later: whole units exactly, the fraction rounded toward zero.
method AddUnits(value: f64, most: i64, scale: i64) -> System.DateTime
// Ticks since 0001-01-01 00:00:00.
constructor DateTime(ticks: i64)
constructor DateTime(ticks: i64, kind: System.DateTimeKind)
constructor DateTime(year: i32, month: i32, day: i32)
constructor DateTime(year: i32, month: i32, day: i32, hour: i32, minute: i32, second: i32)
constructor DateTime(year: i32, month: i32, day: i32, hour: i32, minute: i32, second: i32, kind: System.DateTimeKind)
constructor DateTime(year: i32, month: i32, day: i32, hour: i32, minute: i32, second: i32, millisecond: i32)
constructor DateTime(year: i32, month: i32, day: i32, hour: i32, minute: i32, second: i32, millisecond: i32, kind: System.DateTimeKind)
static method IsLeapYear(year: i32) -> bool
static method DaysInMonth(year: i32, month: i32) -> i32
// The same moment with another kind (the clock reading is not changed).
static method SpecifyKind(value: System.DateTime, kind: System.DateTimeKind) -> System.DateTime
method Add(span: System.TimeSpan) -> System.DateTime
method AddTicks(value: i64) -> System.DateTime
method AddDays(value: f64) -> System.DateTime
method AddHours(value: f64) -> System.DateTime
method AddMinutes(value: f64) -> System.DateTime
method AddSeconds(value: f64) -> System.DateTime
method AddMilliseconds(value: f64) -> System.DateTime
method AddMicroseconds(value: f64) -> System.DateTime
// `months` months later: the same day, or the month's last day when it is shorter.
method AddMonths(months: i32) -> System.DateTime
method AddYears(years: i32) -> System.DateTime
// The time from `other` to this moment, and this moment `span` earlier.
method Subtract(other: System.DateTime) -> System.TimeSpan
method Subtract(span: System.TimeSpan) -> System.DateTime
static operator $op_Add(d: System.DateTime, span: System.TimeSpan) -> System.DateTime
static operator $op_Subtract(d: System.DateTime, span: System.TimeSpan) -> System.DateTime
static operator $op_Subtract(a: System.DateTime, b: System.DateTime) -> System.TimeSpan
static operator $op_Equal(a: System.DateTime, b: System.DateTime) -> bool
static operator $op_NotEqual(a: System.DateTime, b: System.DateTime) -> bool
static operator $op_Less(a: System.DateTime, b: System.DateTime) -> bool
static operator $op_LessEqual(a: System.DateTime, b: System.DateTime) -> bool
static operator $op_Greater(a: System.DateTime, b: System.DateTime) -> bool
static operator $op_GreaterEqual(a: System.DateTime, b: System.DateTime) -> bool
// The same moment (the kind is not compared).
method Equals(other: System.DateTime) -> bool
method Hash() -> u64
method CompareTo(other: System.DateTime) -> i32
static method Compare(a: System.DateTime, b: System.DateTime) -> i32
// The moment on UTC's clock and on the local time zone's (Unspecified counts as the other one).
method ToUniversalTime() -> System.DateTime
method ToLocalTime() -> System.DateTime
// Seconds and milliseconds since 1970-01-01 UTC (Unspecified counts as UTC), and the UTC moment of a count of
// them.
method ToUnixTimeSeconds() -> i64
method ToUnixTimeMilliseconds() -> i64
static method FromUnixTimeSeconds(seconds: i64) -> System.DateTime
static method FromUnixTimeMilliseconds(milliseconds: i64) -> System.DateTime
// `MM/dd/yyyy HH:mm:ss`.
method ToString() -> System.String<u8>
// As text by a format: a standard one (d, D, f, F, g, G, M, o, R, s, t, T, u, U, Y) or a custom one of
// yyyy, yy, MMMM, MMM, MM, M, dddd, ddd, dd, d, HH, H, hh, h, mm, m, ss, s, f…, F…, tt, t, K, zzz, zz, z,
// 'text', "text" and \x.
method ToString(format: System.String<u8>) -> System.String<u8>
// The moment `text` writes: ISO 8601 (`2024-05-01`, `2024-05-01T13:45:30.5Z`, `…+02:00`), the invariant
// culture's `05/01/2024 1:45 PM`, `Wed, 01 May 2024 13:45:30 GMT`, `1 May 2024`, `May 1, 2024`, or a time
// alone (today); a FormatError when it writes none.
static method Parse(text: System.String<u8>) -> System.DateTime
static method Parse(text: System.String<u8>, styles: System.DateTimeStyles) -> System.DateTime
// The moment `text` writes in exactly `format` (a standard or custom format, as ToString takes).
static method ParseExact(text: System.String<u8>, format: System.String<u8>) -> System.DateTime
static method ParseExact(text: System.String<u8>, format: System.String<u8>, styles: System.DateTimeStyles) -> System.DateTime
// The moment, or null when `text` writes none.
static method TryParse(text: System.String<u8>) -> System.DateTime?
static method TryParse(text: System.String<u8>, styles: System.DateTimeStyles) -> System.DateTime?
static method TryParseExact(text: System.String<u8>, format: System.String<u8>) -> System.DateTime?
static method TryParseExact(text: System.String<u8>, format: System.String<u8>, styles: System.DateTimeStyles) -> System.DateTime?
// The bits (ticks and kind), and a DateTime from them.
method ToBinary() -> i64
static method FromBinary(bits: i64) -> System.DateTime
static property MinValue: System.DateTime
static property MaxValue: System.DateTime
// 1970-01-01 00:00:00 UTC.
static property UnixEpoch: System.DateTime
// Now: in UTC, in the local time zone, and today's date (local, at midnight).
static property UtcNow: System.DateTime
static property Now: System.DateTime
static property Today: System.DateTime
property Ticks: i64
property Kind: System.DateTimeKind
property Year: i32
property Month: i32
property Day: i32
property Hour: i32
property Minute: i32
property Second: i32
property Millisecond: i32
property Microsecond: i32
property Nanosecond: i32
property DayOfWeek: System.DayOfWeek
// 1 for January 1st.
property DayOfYear: i32
// The date at midnight (same kind), and the time since midnight.
property Date: System.DateTime
property TimeOfDay: System.TimeSpan
}