Class ICalDateTime
An iCalendar date-time value (RFC 5545 §3.3.5). Can be UTC, local (with a TZID parameter), or date-only. Immutable after construction.
Inherited Members
Namespace: DRIT.Mail.Rfc.ICal
Assembly: DRIT.Mail.dll
Syntax
public sealed class ICalDateTime
Constructors
View SourceICalDateTime(DateTime, bool, bool, string?)
Initializes a new instance of the ICalDateTime class.
Declaration
public ICalDateTime(DateTime value, bool isUtc, bool isDateOnly, string? timeZoneId)
Parameters
| Type | Name | Description |
|---|---|---|
| DateTime | value | The date-time value. |
| bool | isUtc |
|
| bool | isDateOnly |
|
| string | timeZoneId | The TZID parameter value, or null for UTC/floating. |
Properties
View SourceIsDateOnly
Gets a value indicating whether the value is a date with no time component
(VALUE=DATE).
Declaration
public bool IsDateOnly { get; }
Property Value
| Type | Description |
|---|---|
| bool |
IsUtc
Gets a value indicating whether the date-time is in UTC (has a trailing Z).
Declaration
public bool IsUtc { get; }
Property Value
| Type | Description |
|---|---|
| bool |
TimeZoneId
Gets the TZID parameter value, or null if the date-time is UTC or floating.
Declaration
public string? TimeZoneId { get; }
Property Value
| Type | Description |
|---|---|
| string |
Value
Gets the date-time value.
Declaration
public DateTime Value { get; }
Property Value
| Type | Description |
|---|---|
| DateTime |
Methods
View SourceAsDateTimeOffset(TimeZoneInfo?)
Converts this date-time to a DateTimeOffset. If this date-time is
UTC, the offset is Zero. If a tz is
provided and has a matching TimeZoneId, that timezone's offset is
used. Otherwise the local offset is assumed.
Declaration
public DateTimeOffset AsDateTimeOffset(TimeZoneInfo? tz = null)
Parameters
| Type | Name | Description |
|---|---|---|
| TimeZoneInfo | tz | Specifies the tz value. |
Returns
| Type | Description |
|---|---|
| DateTimeOffset |
Parse(string)
Parses an iCalendar date-time or date value (RFC 5545 §3.3.5). Supports:
YYYYMMDDTHHMMSSZ (UTC), YYYYMMDDTHHMMSS (local), and
YYYYMMDD (date only). The TZID is set separately from the parsing of the
property's TZID parameter; this method only parses the raw value text.
Declaration
public static ICalDateTime Parse(string text)
Parameters
| Type | Name | Description |
|---|---|---|
| string | text | Specifies the text value. |
Returns
| Type | Description |
|---|---|
| ICalDateTime |
ToString()
Formats this date-time for iCalendar serialization. Date-only produces
YYYYMMDD; UTC produces YYYYMMDDTHHMMSSZ; local produces
YYYYMMDDTHHMMSS.
Declaration
public override string ToString()
Returns
| Type | Description |
|---|---|
| string |