Legend

Class
Struct
Enum
Interface
Delegate
Constructor
Method
Property
Event
Field

Extension method: string ToIsoStringOptimal(this DateTime, IsoDateFormat, IsoDatePrecision, IsoDatePrecision, bool)

Declaration

public static string ToIsoStringOptimal(
    this DateTime datetime,
    IsoDateFormat format = IsoDateFormat.HumanReadable,
    IsoDatePrecision minPrecision = IsoDatePrecision.Days,
    IsoDatePrecision maxPrecision = IsoDatePrecision.Full,
    bool includeTimezone = false
)

Summary

Returns a string representation of the date/time in an ISO-8601-like format. The function will omit higher-precision parts whose values are zeroes, as permitted by the standard.

Parameters

this DateTimedatetimeDate/time to convert.
IsoDateFormatformatOne of the several pre-defined formats to use.
IsoDatePrecisionminPrecisionMinimum precision of the resulting string. The actual precision is determined by what's available in the date/time, bounded by this parameter.
IsoDatePrecisionmaxPrecisionMaximum precision of the resulting string. Any higher-precision parts are truncated.
boolincludeTimezoneSpecifies whether a suffix indicating date/time kind (local/utc/unspecified) and, for local times, a UTC offset, is appended.