/// <summary> /// <para>Specifies a custom format to use.</para> /// <para>See https://docs.microsoft.com/en-us/dotnet/standard/base-types/custom-timespan-format-strings for more details.</para> /// </summary> /// <param name="format">Custom format string to use.</param> public TimeSpanFormatAttribute(string format) { if (string.IsNullOrWhiteSpace(format)) { throw new ArgumentNullException(nameof(format), "Specified format cannot be null or empty."); } this.Kind = TimeSpanFormatKind.Custom; this.Format = format; }
/// <summary> /// Specifies a predefined format to use. /// </summary> /// <param name="kind">Predefined format kind to use.</param> public TimeSpanFormatAttribute(TimeSpanFormatKind kind) { if (kind < 0 || kind > TimeSpanFormatKind.InvariantLocaleShort) { throw new ArgumentOutOfRangeException(nameof(kind), "Specified format kind is not legal or supported."); } this.Kind = kind; this.Format = null; }