23 instantiations of DateOnly
Aspire.Hosting.RemoteHost.Tests (2)
Microsoft.AspNetCore.Components.Endpoints.Tests (4)
Binding\FormDataMapperTests.cs (2)
2124{ "04/20/2023", typeof(DateOnly?), new DateOnly?(new DateOnly(2023, 04, 20))},
2209{ "04/20/2023", typeof(DateOnly), new DateOnly(2023, 04, 20) },
Microsoft.AspNetCore.Components.Tests (2)
Microsoft.AspNetCore.Mvc.TagHelpers.Test (2)
Microsoft.Extensions.AI.Abstractions.Tests (1)
Microsoft.Gen.Logging.Generated.Tests (1)
Shared.Tests (1)
System.Private.CoreLib (10)
352 references to DateOnly
Aspire.Hosting (3)
Aspire.Hosting.RemoteHost.Tests (3)
Aspire.Hosting.Testing.Tests (2)
Aspire.Templates.Tests (1)
AspireJavaScript.MinimalApi (2)
aspire-server (5)
AspireWithMaui.WeatherApi (2)
AspireWithNode.AspNetCoreApi (2)
BlazorUnitedApp (3)
Deployers.ApiService (2)
Keycloak.ApiService (2)
Keycloak.Web (1)
Microsoft.AspNetCore.Components (74)
BindConverter.cs (36)
499public static string FormatValue(DateOnly value, CultureInfo? culture = null) => FormatDateOnlyValueCore(value, format: null, culture);
505/// <param name="format">The format to use. Provided to <see cref="DateOnly.ToString(string, IFormatProvider)"/>.</param>
511public static string FormatValue(DateOnly value, [StringSyntax(StringSyntaxAttribute.DateOnlyFormat)] string format, CultureInfo? culture = null) => FormatDateOnlyValueCore(value, format, culture);
513private static string FormatDateOnlyValueCore(DateOnly value, string? format, CultureInfo? culture)
524private static string FormatDateOnlyValueCore(DateOnly value, CultureInfo? culture)
538public static string? FormatValue(DateOnly? value, CultureInfo? culture = null) => FormatNullableDateOnlyValueCore(value, format: null, culture);
544/// <param name="format">The format to use. Provided to <see cref="DateOnly.ToString(string, IFormatProvider)"/>.</param>
550public static string? FormatValue(DateOnly? value, [StringSyntax(StringSyntaxAttribute.DateOnlyFormat)] string format, CultureInfo? culture = null) => FormatNullableDateOnlyValueCore(value, format, culture);
552private static string? FormatNullableDateOnlyValueCore(DateOnly? value, string? format, CultureInfo? culture)
568private static string? FormatNullableDateOnlyValueCore(DateOnly? value, CultureInfo? culture)
593/// <param name="format">The format to use. Provided to <see cref="DateOnly.ToString(string, IFormatProvider)"/>.</param>
632/// <param name="format">The format to use. Provided to <see cref="DateOnly.ToString(string, IFormatProvider)"/>.</param>
1394/// Attempts to convert a value to a <see cref="System.DateOnly"/>.
1400public static bool TryConvertToDateOnly(object? obj, CultureInfo? culture, out DateOnly value)
1406/// Attempts to convert a value to a <see cref="System.DateOnly"/>.
1413public static bool TryConvertToDateOnly(object? obj, CultureInfo? culture, [StringSyntax(StringSyntaxAttribute.DateOnlyFormat)] string format, out DateOnly value)
1419/// Attempts to convert a value to a nullable <see cref="System.DateOnly"/>.
1425public static bool TryConvertToNullableDateOnly(object? obj, CultureInfo? culture, out DateOnly? value)
1431/// Attempts to convert a value to a nullable <see cref="System.DateOnly"/>.
1438public static bool TryConvertToNullableDateOnly(object? obj, CultureInfo? culture, [StringSyntax(StringSyntaxAttribute.DateOnlyFormat)] string format, out DateOnly? value)
1443internal static BindParser<DateOnly> ConvertToDateOnly = ConvertToDateOnlyCore;
1444internal static BindParserWithFormat<DateOnly> ConvertToDateOnlyWithFormat = ConvertToDateOnlyCore;
1445internal static BindParser<DateOnly?> ConvertToNullableDateOnly = ConvertToNullableDateOnlyCore;
1446internal static BindParserWithFormat<DateOnly?> ConvertToNullableDateOnlyWithFormat = ConvertToNullableDateOnlyCore;
1448private static bool ConvertToDateOnlyCore(object? obj, CultureInfo? culture, out DateOnly value)
1453private static bool ConvertToDateOnlyCore(object? obj, CultureInfo? culture, string? format, out DateOnly value)
1458value = DateOnly.FromDateTime(dateTime);
1466private static bool ConvertToNullableDateOnlyCore(object? obj, CultureInfo? culture, out DateOnly? value)
1471private static bool ConvertToNullableDateOnlyCore(object? obj, CultureInfo? culture, string? format, out DateOnly? value)
1476value = DateOnly.FromDateTime(dateTime);
1775else if (typeof(T) == typeof(DateOnly))
1777formatter = (BindFormatter<DateOnly>)FormatDateOnlyValueCore;
1779else if (typeof(T) == typeof(DateOnly?))
1781formatter = (BindFormatter<DateOnly?>)FormatNullableDateOnlyValueCore;
1974else if (typeof(T) == typeof(DateOnly))
1978else if (typeof(T) == typeof(DateOnly?))
EventCallbackFactoryBinderExtensions.cs (24)
974Action<DateOnly> setter,
975DateOnly existingValue,
978return CreateBinderCore<DateOnly>(factory, receiver, setter, culture, ConvertToDateOnly);
994Func<DateOnly, Task> setter,
995DateOnly existingValue,
998return CreateBinderCoreAsync<DateOnly>(factory, receiver, setter, culture, ConvertToDateOnly);
1015Action<DateOnly> setter,
1016DateOnly existingValue,
1020return CreateBinderCore<DateOnly>(factory, receiver, setter, culture, format, ConvertToDateOnlyWithFormat);
1037Func<DateOnly, Task> setter,
1038DateOnly existingValue,
1042return CreateBinderCoreAsync<DateOnly>(factory, receiver, setter, culture, format, ConvertToDateOnlyWithFormat);
1058Action<DateOnly?> setter,
1059DateOnly? existingValue,
1062return CreateBinderCore<DateOnly?>(factory, receiver, setter, culture, ConvertToNullableDateOnly);
1078Func<DateOnly?, Task> setter,
1079DateOnly? existingValue,
1082return CreateBinderCoreAsync<DateOnly?>(factory, receiver, setter, culture, ConvertToNullableDateOnly);
1099Action<DateOnly?> setter,
1100DateOnly? existingValue,
1104return CreateBinderCore<DateOnly?>(factory, receiver, setter, culture, format, ConvertToNullableDateOnlyWithFormat);
1121Func<DateOnly?, Task> setter,
1122DateOnly? existingValue,
1126return CreateBinderCoreAsync<DateOnly?>(factory, receiver, setter, culture, format, ConvertToNullableDateOnlyWithFormat);
Microsoft.AspNetCore.Components.Endpoints (7)
Microsoft.AspNetCore.Components.Endpoints.Tests (24)
Binding\FormDataMapperTests.cs (4)
2124{ "04/20/2023", typeof(DateOnly?), new DateOnly?(new DateOnly(2023, 04, 20))},
2166{ typeof(DateOnly?) },
2209{ "04/20/2023", typeof(DateOnly), new DateOnly(2023, 04, 20) },
FormMapping\Converters\NullableConverterTests.cs (20)
18var nullableConverter = new NullableConverter<DateOnly>(new ParsableConverter<DateOnly>());
30var date = new DateOnly(2023, 11, 30);
33var nullableConverter = new NullableConverter<DateOnly>(new ParsableConverter<DateOnly>());
47var nullableConverter = new NullableConverter<DateOnly>(new ParsableConverter<DateOnly>());
70var nullableConverter = new NullableConverter<DateOnly>(new ParsableConverter<DateOnly>());
72var returnValue = nullableConverter.TryRead(ref reader, typeof(DateOnly?), default, out var result, out var found);
93var nullableConverter = new NullableConverter<DateOnly>(new ParsableConverter<DateOnly>());
95var returnValue = nullableConverter.TryRead(ref reader, typeof(DateOnly?), default, out var result, out var found);
106var date = new DateOnly(2023, 11, 30);
117var nullableConverter = new NullableConverter<DateOnly>(new ParsableConverter<DateOnly>());
119var returnValue = nullableConverter.TryRead(ref reader, typeof(DateOnly?), default, out var result, out var found);
143var nullableConverter = new NullableConverter<DateOnly>(new ParsableConverter<DateOnly>());
145var returnValue = nullableConverter.TryRead(ref reader, typeof(DateOnly?), default, out var result, out var found);
Microsoft.AspNetCore.Components.Tests (6)
Microsoft.AspNetCore.Components.Web (3)
Microsoft.AspNetCore.Http.Extensions (11)
Microsoft.AspNetCore.Mvc.Abstractions (4)
Microsoft.AspNetCore.Mvc.ApiExplorer (1)
Microsoft.AspNetCore.Mvc.ApiExplorer.Test (4)
Microsoft.AspNetCore.Mvc.TagHelpers (1)
Microsoft.AspNetCore.Mvc.TagHelpers.Test (6)
Microsoft.AspNetCore.OpenApi (6)
Microsoft.AspNetCore.OpenApi.Tests (4)
Microsoft.Extensions.AI.Abstractions.Tests (3)
Microsoft.Extensions.AI.Integration.Tests (1)
Microsoft.Extensions.Validation (1)
Microsoft.Extensions.Validation.Tests (1)
Microsoft.Gen.Logging.Generated.Tests (1)
PresentationCore.Tests (1)
Sample (1)
Shared.Tests (2)
Stress.ApiService (2)
System.Collections.Immutable (1)
System.ComponentModel.TypeConverter (13)
System\ComponentModel\DateOnlyConverter.cs (12)
11/// Provides a type converter to convert <see cref='System.DateOnly'/> objects to and from various other representations.
16/// Gets a value indicating whether this converter can convert an object in the given source type to a <see cref='System.DateOnly'/>
32/// Converts the given value object to a <see cref='System.DateOnly'/> object.
42return DateOnly.MinValue;
57return DateOnly.Parse(text, formatInfo);
61return DateOnly.Parse(text, culture);
66throw new FormatException(SR.Format(SR.ConvertInvalidPrimitive, (string)value, nameof(DateOnly)), e);
74/// Converts the given value object from a <see cref='System.DateOnly'/> object using the arguments.
79if (destinationType == typeof(string) && value is DateOnly dateOnly)
81if (dateOnly == DateOnly.MinValue)
96if (destinationType == typeof(InstanceDescriptor) && value is DateOnly date)
98return new InstanceDescriptor(typeof(DateOnly).GetConstructor(new Type[] { typeof(int), typeof(int), typeof(int) }), new object[] { date.Year, date.Month, date.Day });
System.Private.CoreLib (80)
src\libraries\System.Private.CoreLib\src\System\DateOnly.cs (61)
18IComparable<DateOnly>,
19IEquatable<DateOnly>,
21ISpanParsable<DateOnly>,
45public static DateOnly MinValue => new DateOnly(MinDayNumber);
50public static DateOnly MaxValue => new DateOnly(MaxDayNumber);
73public static DateOnly FromDayNumber(int dayNumber)
121public DateOnly AddDays(int value)
139public DateOnly AddMonths(int value) => new DateOnly(DayNumberFromDateTime(GetEquivalentDateTime().AddMonths(value)));
146public DateOnly AddYears(int value) => new DateOnly(DayNumberFromDateTime(GetEquivalentDateTime().AddYears(value)));
154public static bool operator ==(DateOnly left, DateOnly right) => left._dayNumber == right._dayNumber;
162public static bool operator !=(DateOnly left, DateOnly right) => left._dayNumber != right._dayNumber;
170public static bool operator >(DateOnly left, DateOnly right) => left._dayNumber > right._dayNumber;
178public static bool operator >=(DateOnly left, DateOnly right) => left._dayNumber >= right._dayNumber;
186public static bool operator <(DateOnly left, DateOnly right) => left._dayNumber < right._dayNumber;
194public static bool operator <=(DateOnly left, DateOnly right) => left._dayNumber <= right._dayNumber;
197/// Deconstructs <see cref="DateOnly"/> by <see cref="Year"/>, <see cref="Month"/> and <see cref="Day"/>.
232public static DateOnly FromDateTime(DateTime dateTime) => new DateOnly(DayNumberFromDateTime(dateTime));
239public int CompareTo(DateOnly value) => _dayNumber.CompareTo(value._dayNumber);
249if (value is not DateOnly dateOnly)
262public bool Equals(DateOnly value) => _dayNumber == value._dayNumber;
269public override bool Equals([NotNullWhen(true)] object? value) => value is DateOnly dateOnly && _dayNumber == dateOnly._dayNumber;
287public static DateOnly Parse(ReadOnlySpan<char> s, IFormatProvider? provider = default, DateTimeStyles style = DateTimeStyles.None)
294ParseFailureKind result = TryParseInternal(s, provider, style, out DateOnly dateOnly);
315public static DateOnly ParseExact(ReadOnlySpan<char> s, [StringSyntax(StringSyntaxAttribute.DateOnlyFormat)] ReadOnlySpan<char> format, IFormatProvider? provider = default, DateTimeStyles style = DateTimeStyles.None)
322ParseFailureKind result = TryParseExactInternal(s, format, provider, style, out DateOnly dateOnly);
339public static DateOnly ParseExact(ReadOnlySpan<char> s, [StringSyntax(StringSyntaxAttribute.DateOnlyFormat)] string[] formats) => ParseExact(s, formats, null, DateTimeStyles.None);
350public static DateOnly ParseExact(ReadOnlySpan<char> s, [StringSyntax(StringSyntaxAttribute.DateOnlyFormat)] string[] formats, IFormatProvider? provider, DateTimeStyles style = DateTimeStyles.None)
371ParseFailureKind result = TryParseExactInternal(s, formats, provider, style, out DateOnly dateOnly);
385public static DateOnly Parse(string s) => Parse(s, null, DateTimeStyles.None);
394public static DateOnly Parse(string s, IFormatProvider? provider, DateTimeStyles style = DateTimeStyles.None)
407public static DateOnly ParseExact(string s, [StringSyntax(StringSyntaxAttribute.DateOnlyFormat)] string format) => ParseExact(s, format, null, DateTimeStyles.None);
418public static DateOnly ParseExact(string s, [StringSyntax(StringSyntaxAttribute.DateOnlyFormat)] string format, IFormatProvider? provider, DateTimeStyles style = DateTimeStyles.None)
432public static DateOnly ParseExact(string s, [StringSyntax(StringSyntaxAttribute.DateOnlyFormat)] string[] formats) => ParseExact(s, formats, null, DateTimeStyles.None);
443public static DateOnly ParseExact(string s, [StringSyntax(StringSyntaxAttribute.DateOnlyFormat)] string[] formats, IFormatProvider? provider, DateTimeStyles style = DateTimeStyles.None)
455public static bool TryParse(ReadOnlySpan<char> s, out DateOnly result) => TryParse(s, null, DateTimeStyles.None, out result);
465public static bool TryParse(ReadOnlySpan<char> s, IFormatProvider? provider, DateTimeStyles style, out DateOnly result)
476private static ParseFailureKind TryParseInternal(ReadOnlySpan<char> s, IFormatProvider? provider, DateTimeStyles style, out DateOnly result)
505public static bool TryParseExact(ReadOnlySpan<char> s, [StringSyntax(StringSyntaxAttribute.DateOnlyFormat)] ReadOnlySpan<char> format, out DateOnly result) => TryParseExact(s, format, null, DateTimeStyles.None, out result);
517public static bool TryParseExact(ReadOnlySpan<char> s, [StringSyntax(StringSyntaxAttribute.DateOnlyFormat)] ReadOnlySpan<char> format, IFormatProvider? provider, DateTimeStyles style, out DateOnly result)
535private static ParseFailureKind TryParseExactInternal(ReadOnlySpan<char> s, ReadOnlySpan<char> format, IFormatProvider? provider, DateTimeStyles style, out DateOnly result)
582public static bool TryParseExact(ReadOnlySpan<char> s, [NotNullWhen(true), StringSyntax(StringSyntaxAttribute.DateOnlyFormat)] string?[]? formats, out DateOnly result) => TryParseExact(s, formats, null, DateTimeStyles.None, out result);
593public static bool TryParseExact(ReadOnlySpan<char> s, [NotNullWhen(true), StringSyntax(StringSyntaxAttribute.DateOnlyFormat)] string?[]? formats, IFormatProvider? provider, DateTimeStyles style, out DateOnly result)
617private static ParseFailureKind TryParseExactInternal(ReadOnlySpan<char> s, string?[]? formats, IFormatProvider? provider, DateTimeStyles style, out DateOnly result)
669public static bool TryParse([NotNullWhen(true)] string? s, out DateOnly result) => TryParse(s, null, DateTimeStyles.None, out result);
679public static bool TryParse([NotNullWhen(true)] string? s, IFormatProvider? provider, DateTimeStyles style, out DateOnly result)
698public static bool TryParseExact([NotNullWhen(true)] string? s, [NotNullWhen(true), StringSyntax(StringSyntaxAttribute.DateOnlyFormat)] string? format, out DateOnly result) => TryParseExact(s, format, null, DateTimeStyles.None, out result);
710public static bool TryParseExact([NotNullWhen(true)] string? s, [NotNullWhen(true), StringSyntax(StringSyntaxAttribute.DateOnlyFormat)] string? format, IFormatProvider? provider, DateTimeStyles style, out DateOnly result)
728public static bool TryParseExact([NotNullWhen(true)] string? s, [NotNullWhen(true), StringSyntax(StringSyntaxAttribute.DateOnlyFormat)] string?[]? formats, out DateOnly result) => TryParseExact(s, formats, null, DateTimeStyles.None, out result);
739public static bool TryParseExact([NotNullWhen(true)] string? s, [NotNullWhen(true), StringSyntax(StringSyntaxAttribute.DateOnlyFormat)] string?[]? formats, IFormatProvider? provider, DateTimeStyles style, out DateOnly result)
760throw new FormatException(SR.Format(SR.Format_DateTimeOnlyContainsNoneDateParts, s.ToString(), nameof(DateOnly)));
882throw new FormatException(SR.Format(SR.Format_DateTimeOnlyContainsNoneDateParts, format.ToString(), nameof(DateOnly)));
893public static DateOnly Parse(string s, IFormatProvider? provider) => Parse(s, provider, DateTimeStyles.None);
896public static bool TryParse([NotNullWhen(true)] string? s, IFormatProvider? provider, out DateOnly result) => TryParse(s, provider, DateTimeStyles.None, out result);
903public static DateOnly Parse(ReadOnlySpan<char> s, IFormatProvider? provider) => Parse(s, provider, DateTimeStyles.None);
906public static bool TryParse(ReadOnlySpan<char> s, IFormatProvider? provider, out DateOnly result) => TryParse(s, provider, DateTimeStyles.None, out result);
System.Private.DataContractSerialization (16)
System.Private.Xml (32)
System.Runtime (1)
System.Text.Json (13)
System\Text\Json\Serialization\Converters\Value\DateOnlyConverter.cs (7)
10internal sealed class DateOnlyConverter : JsonPrimitiveConverter<DateOnly>
15public override DateOnly Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
25internal override DateOnly ReadAsPropertyNameCore(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
31private static DateOnly ReadCore(ref Utf8JsonReader reader)
57if (!JsonHelpers.TryParseAsIso(source, out DateOnly value))
65public override void Write(Utf8JsonWriter writer, DateOnly value, JsonSerializerOptions options)
73internal override void WriteAsPropertyNameCore(Utf8JsonWriter writer, DateOnly value, JsonSerializerOptions options, bool isWritingExtensionDataProperty)
TestingAppHost1.MyWebApp (2)
Yarp.Backend (2)