321 instantiations of DateTimeOffset
Aspire.Dashboard.Components.Tests (1)
Aspire.Hosting.Testing.Tests (1)
Aspire.Hosting.Tests (4)
VersionChecking\VersionCheckServiceTests.cs (3)
68var currentDate = new DateTimeOffset(2000, 12, 29, 20, 59, 59, TimeSpan.Zero);
103var currentDate = new DateTimeOffset(2000, 12, 29, 20, 59, 59, TimeSpan.Zero);
210public DateTimeOffset UtcNow { get; set; } = new DateTimeOffset(2000, 12, 29, 20, 59, 59, TimeSpan.Zero);
dotnet-svcutil-lib (10)
FilesWebSite (2)
Controllers\DownloadFilesController.cs (2)
30var lastModified = new DateTimeOffset(year: 1999, month: 11, day: 04, hour: 3, minute: 0, second: 0, offset: new TimeSpan(0));
44var lastModified = new DateTimeOffset(year: 1999, month: 11, day: 04, hour: 3, minute: 0, second: 0, offset: new TimeSpan(0));
InMemory.FunctionalTests (2)
Microsoft.AspNetCore.Authentication (1)
Microsoft.AspNetCore.Authentication.Core.Test (10)
AuthenticationPropertiesTests.cs (10)
199props.IssuedUtc = new DateTimeOffset(new DateTime(2018, 03, 21, 0, 0, 0, DateTimeKind.Utc));
200Assert.Equal(new DateTimeOffset(new DateTime(2018, 03, 21, 0, 0, 0, DateTimeKind.Utc)), props.IssuedUtc);
213props.ExpiresUtc = new DateTimeOffset(new DateTime(2018, 03, 19, 12, 34, 56, DateTimeKind.Utc));
214Assert.Equal(new DateTimeOffset(new DateTime(2018, 03, 19, 12, 34, 56, DateTimeKind.Utc)), props.ExpiresUtc);
244props.SetDateTimeOffset("foo", new DateTimeOffset(new DateTime(2018, 03, 19, 12, 34, 56, DateTimeKind.Utc)));
258var dateTimeOffset = new DateTimeOffset(new DateTime(2018, 03, 19, 12, 34, 56, DateTimeKind.Utc));
311ExpiresUtc = new DateTimeOffset(2021, 03, 28, 13, 47, 00, TimeSpan.Zero),
312IssuedUtc = new DateTimeOffset(2021, 03, 28, 12, 47, 00, TimeSpan.Zero),
367ExpiresUtc = new DateTimeOffset(2021, 03, 28, 13, 47, 00, TimeSpan.Zero),
368IssuedUtc = new DateTimeOffset(2021, 03, 28, 12, 47, 00, TimeSpan.Zero),
Microsoft.AspNetCore.Authorization.Test (2)
AuthorizationMiddlewareTests.cs (2)
823var firstExpiration = new DateTimeOffset(2021, 5, 12, 2, 3, 4, TimeSpan.Zero);
824var secondExpiration = new DateTimeOffset(2021, 5, 11, 2, 3, 4, TimeSpan.Zero);
Microsoft.AspNetCore.Components.Endpoints.Tests (2)
Binding\FormDataMapperTests.cs (2)
2126{ "4/20/2023 12:56:34 PM +02:00", typeof(DateTimeOffset?), new DateTimeOffset?(new DateTimeOffset(2023, 04, 20, 12, 56, 34, TimeSpan.FromHours(2)))},
2211{ "4/20/2023 12:56:34 PM +02:00", typeof(DateTimeOffset), new DateTimeOffset(2023, 04, 20, 12, 56, 34, TimeSpan.FromHours(2)) },
Microsoft.AspNetCore.Components.Server.Tests (1)
Microsoft.AspNetCore.Components.Tests (3)
SupplyParameterFromPersistentComponentStateValueProviderTests.cs (2)
232{ new DateTimeOffset(2023, 1, 1, 0, 0, 0, TimeSpan.FromSeconds(0)), new DateTimeOffset(2023, 12, 31, 0, 0, 0, TimeSpan.FromSeconds(0)) },
Microsoft.AspNetCore.DataProtection.Extensions (1)
Microsoft.AspNetCore.DataProtection.Tests (7)
KeyManagement\XmlKeyManagerTests.cs (7)
78var creationDate = new DateTimeOffset(2014, 01, 01, 0, 0, 0, TimeSpan.Zero);
79var activationDate = new DateTimeOffset(2014, 02, 01, 0, 0, 0, TimeSpan.Zero);
80var expirationDate = new DateTimeOffset(2014, 03, 01, 0, 0, 0, TimeSpan.Zero);
165var creationDate = new DateTimeOffset(2014, 01, 01, 0, 0, 0, TimeSpan.Zero);
166var activationDate = new DateTimeOffset(2014, 02, 01, 0, 0, 0, TimeSpan.Zero);
167var expirationDate = new DateTimeOffset(2014, 03, 01, 0, 0, 0, TimeSpan.Zero);
685var revocationDate = new DateTimeOffset(2014, 01, 01, 0, 0, 0, TimeSpan.Zero);
Microsoft.AspNetCore.DeveloperCertificates.XPlat.Tests (16)
CertificateManagerTests.cs (16)
45now = new DateTimeOffset(now.Year, now.Month, now.Day, now.Hour, now.Minute, now.Second, 0, now.Offset);
138now = new DateTimeOffset(now.Year, now.Month, now.Day, now.Hour, now.Minute, now.Second, 0, now.Offset);
170now = new DateTimeOffset(now.Year, now.Month, now.Day, now.Hour, now.Minute, now.Second, 0, now.Offset);
203now = new DateTimeOffset(now.Year, now.Month, now.Day, now.Hour, now.Minute, now.Second, 0, now.Offset);
234now = new DateTimeOffset(now.Year, now.Month, now.Day, now.Hour, now.Minute, now.Second, 0, now.Offset);
267now = new DateTimeOffset(now.Year, now.Month, now.Day, now.Hour, now.Minute, now.Second, 0, now.Offset);
294now = new DateTimeOffset(now.Year, now.Month, now.Day, now.Hour, now.Minute, now.Second, 0, now.Offset);
334now = new DateTimeOffset(now.Year, now.Month, now.Day, now.Hour, now.Minute, now.Second, 0, now.Offset);
365now = new DateTimeOffset(now.Year, now.Month, now.Day, now.Hour, now.Minute, now.Second, 0, now.Offset);
385now = new DateTimeOffset(now.Year, now.Month, now.Day, now.Hour, now.Minute, now.Second, 0, now.Offset);
403now = new DateTimeOffset(now.Year, now.Month, now.Day, now.Hour, now.Minute, now.Second, 0, now.Offset);
424now = new DateTimeOffset(now.Year, now.Month, now.Day, now.Hour, now.Minute, now.Second, 0, now.Offset);
445now = new DateTimeOffset(now.Year, now.Month, now.Day, now.Hour, now.Minute, now.Second, 0, now.Offset);
462now = new DateTimeOffset(now.Year, now.Month, now.Day, now.Hour, now.Minute, now.Second, 0, now.Offset);
480now = new DateTimeOffset(now.Year, now.Month, now.Day, now.Hour, now.Minute, now.Second, 0, now.Offset);
531now = new DateTimeOffset(now.Year, now.Month, now.Day, now.Hour, now.Minute, now.Second, 0, now.Offset);
Microsoft.AspNetCore.Grpc.JsonTranscoding.Tests (3)
ConverterTests\JsonConverterWriteTests.cs (2)
285TimestampValue = Timestamp.FromDateTimeOffset(new DateTimeOffset(2020, 12, 1, 12, 30, 0, TimeSpan.FromHours(12)))
294var ts = Timestamp.FromDateTimeOffset(new DateTimeOffset(2020, 12, 1, 12, 30, 0, TimeSpan.FromHours(12)));
Microsoft.AspNetCore.Http.Extensions.Tests (1)
Microsoft.AspNetCore.Http.Results.Tests (27)
ResultsTests.cs (5)
285new object[] { 0, "text/plain", "testfile", true, new DateTimeOffset(2022, 1, 1, 0, 0, 1, TimeSpan.FromHours(-8)), EntityTagHeaderValue.Any },
287new object[] { 1, "text/plain", "testfile", true, new DateTimeOffset(2022, 1, 1, 0, 0, 1, TimeSpan.FromHours(-8)), EntityTagHeaderValue.Any },
333new object[] { 0, "text/plain", "testfile", true, new DateTimeOffset(2022, 1, 1, 0, 0, 1, TimeSpan.FromHours(-8)), EntityTagHeaderValue.Any },
335new object[] { 1, "text/plain", "testfile", true, new DateTimeOffset(2022, 1, 1, 0, 0, 1, TimeSpan.FromHours(-8)), EntityTagHeaderValue.Any },
337new object[] { 2, "text/plain", "testfile", true, new DateTimeOffset(2022, 1, 1, 0, 0, 1, TimeSpan.FromHours(-8)), EntityTagHeaderValue.Any },
TypedResultsTests.cs (7)
263new object[] { 0, "text/plain", "testfile", true, new DateTimeOffset(2022, 1, 1, 0, 0, 1, TimeSpan.FromHours(-8)), EntityTagHeaderValue.Any },
265new object[] { 1, "text/plain", "testfile", true, new DateTimeOffset(2022, 1, 1, 0, 0, 1, TimeSpan.FromHours(-8)), EntityTagHeaderValue.Any },
309new object[] { "text/plain", "testfile", true, new DateTimeOffset(2022, 1, 1, 0, 0, 1, TimeSpan.FromHours(-8)), EntityTagHeaderValue.Any },
311new object[] { "text/plain", "testfile", true, new DateTimeOffset(2022, 1, 1, 0, 0, 1, TimeSpan.FromHours(-8)), EntityTagHeaderValue.Any },
417new object[] { 0, "text/plain", "testfile", true, new DateTimeOffset(2022, 1, 1, 0, 0, 1, TimeSpan.FromHours(-8)), EntityTagHeaderValue.Any },
419new object[] { 1, "text/plain", "testfile", true, new DateTimeOffset(2022, 1, 1, 0, 0, 1, TimeSpan.FromHours(-8)), EntityTagHeaderValue.Any },
421new object[] { 2, "text/plain", "testfile", true, new DateTimeOffset(2022, 1, 1, 0, 0, 1, TimeSpan.FromHours(-8)), EntityTagHeaderValue.Any },
Microsoft.AspNetCore.Http.Tests (1)
Microsoft.AspNetCore.Identity (2)
Microsoft.AspNetCore.Identity.EntityFrameworkCore.Test (1)
Microsoft.AspNetCore.Identity.Specification.Tests (5)
Microsoft.AspNetCore.Identity.Test (1)
Microsoft.AspNetCore.Mvc.Core.Test (37)
FileResultHelperTest.cs (15)
251lastModified = new DateTimeOffset(lastModified.Year, lastModified.Month, lastModified.Day, lastModified.Hour, lastModified.Minute, lastModified.Second, TimeSpan.FromSeconds(0));
329lastModified = new DateTimeOffset(lastModified.Year, lastModified.Month, lastModified.Day, lastModified.Hour, lastModified.Minute, lastModified.Second, TimeSpan.FromSeconds(0));
365lastModified = new DateTimeOffset(lastModified.Year, lastModified.Month, lastModified.Day, lastModified.Hour, lastModified.Minute, lastModified.Second, TimeSpan.FromSeconds(0));
388{ new DateTimeOffset(2018, 4, 9, 11, 23, 22, TimeSpan.Zero), 200 },
389{ new DateTimeOffset(2018, 4, 9, 11, 24, 21, TimeSpan.Zero), 200 },
390{ new DateTimeOffset(2018, 4, 9, 11, 24, 22, TimeSpan.Zero), 304 },
391{ new DateTimeOffset(2018, 4, 9, 11, 24, 23, TimeSpan.Zero), 304 },
392{ new DateTimeOffset(2018, 4, 9, 11, 25, 22, TimeSpan.Zero), 304 },
412LastModified = new DateTimeOffset(ticks, TimeSpan.Zero)
428{ new DateTimeOffset(2018, 4, 9, 11, 23, 22, TimeSpan.Zero), 412 },
429{ new DateTimeOffset(2018, 4, 9, 11, 24, 21, TimeSpan.Zero), 412 },
430{ new DateTimeOffset(2018, 4, 9, 11, 24, 22, TimeSpan.Zero), 200 },
431{ new DateTimeOffset(2018, 4, 9, 11, 24, 23, TimeSpan.Zero), 200 },
432{ new DateTimeOffset(2018, 4, 9, 11, 25, 22, TimeSpan.Zero), 200 },
450LastModified = new DateTimeOffset(ticks, TimeSpan.Zero)
Infrastructure\ActionSelectionTableTest.cs (2)
83new DateTimeOffset(2018, 10, 31, 7, 37, 38, TimeSpan.FromHours(-7)));
123new DateTimeOffset(2018, 10, 31, 7, 37, 38, TimeSpan.FromHours(-7)));
ModelBinding\RouteValueProviderTests.cs (2)
53{ "test-key", new DateTimeOffset(2018, 10, 31, 7, 37, 38, TimeSpan.FromHours(-7)) },
70{ "test-key", new DateTimeOffset(2018, 10, 31, 7, 37, 38, TimeSpan.FromHours(-7)) },
Microsoft.AspNetCore.Mvc.NewtonsoftJson.Test (1)
Microsoft.AspNetCore.Mvc.Razor.Test (1)
Microsoft.AspNetCore.Mvc.RazorPages.Test (1)
Microsoft.AspNetCore.Mvc.TagHelpers.Test (8)
CacheTagHelperTest.cs (3)
326var currentTime = new DateTimeOffset(2010, 1, 1, 0, 0, 0, TimeSpan.Zero);
379var currentTime = new DateTimeOffset(2010, 1, 1, 0, 0, 0, TimeSpan.Zero);
432var currentTime = new DateTimeOffset(2010, 1, 1, 0, 0, 0, TimeSpan.Zero);
DistributedCacheTagHelperTest.cs (3)
349var currentTime = new DateTimeOffset(2010, 1, 1, 0, 0, 0, TimeSpan.Zero);
411var currentTime = new DateTimeOffset(2010, 1, 1, 0, 0, 0, TimeSpan.Zero);
473var currentTime = new DateTimeOffset(2010, 1, 1, 0, 0, 0, TimeSpan.Zero);
Microsoft.AspNetCore.Mvc.ViewFeatures.Test (6)
Microsoft.AspNetCore.OutputCaching (1)
Microsoft.AspNetCore.OutputCaching.StackExchangeRedis (1)
Microsoft.AspNetCore.ResponseCaching.Tests (1)
Microsoft.AspNetCore.Server.Kestrel.Core.Tests (2)
Microsoft.AspNetCore.Session.Tests (1)
Microsoft.AspNetCore.SignalR.Common.Tests (1)
Microsoft.AspNetCore.StaticAssets.Tests (2)
StaticAssetsIntegrationTests.cs (2)
586new("Last-Modified", new DateTimeOffset(2023,03,03,0,0,0,TimeSpan.Zero).ToString("ddd, dd MMM yyyy HH:mm:ss 'GMT'", CultureInfo.InvariantCulture))
1087public DateTimeOffset LastModified => new(2023, 03, 03, 0, 0, 0, TimeSpan.Zero);
Microsoft.AspNetCore.StaticFiles (2)
Microsoft.AspNetCore.StaticFiles.FunctionalTests (1)
Microsoft.AspNetCore.StaticFiles.Tests (5)
StaticFileContextTest.cs (4)
43LastModified = new DateTimeOffset(2014, 1, 2, 3, 4, 5, TimeSpan.Zero)
69LastModified = new DateTimeOffset(2014, 1, 2, 3, 4, 5, TimeSpan.Zero)
98LastModified = new DateTimeOffset(2014, 1, 2, 3, 4, 5, TimeSpan.Zero)
125LastModified = new DateTimeOffset(2014, 1, 2, 3, 4, 5, TimeSpan.Zero)
Microsoft.DotNet.Build.Tasks.Installers (1)
Microsoft.DotNet.XUnitAssert.Tests (21)
EqualityAssertsTests.cs (16)
1812 var expected = new DateTimeOffset(2023, 2, 11, 15, 4, 0, TimeSpan.Zero);
1813 var actual = new DateTimeOffset(2023, 2, 11, 15, 4, 0, TimeSpan.Zero);
1826 var expected = new DateTimeOffset(2023, 2, 11, 15, 4, 0, TimeSpan.Zero);
1827 var actual = new DateTimeOffset(2023, 2, 11, 15, 5, 0, TimeSpan.Zero);
1846 var expected = new DateTimeOffset(2023, 2, 11, 15, 4, 0, TimeSpan.Zero);
1847 var actual = new DateTimeOffset(2023, 2, 11, 16, 4, 0, TimeSpan.FromHours(1));
1859 var expected = new DateTimeOffset(2023, 2, 11, 15, 4, 0, TimeSpan.Zero);
1860 var actual = new DateTimeOffset(2023, 2, 11, 15, 4, 0, TimeSpan.FromHours(1));
1879 var date1 = new DateTimeOffset(2023, 2, 11, 15, 4, 0, TimeSpan.Zero);
1880 var date2 = new DateTimeOffset(2023, 2, 11, 15, 5, 0, TimeSpan.Zero);
1894 var date1 = new DateTimeOffset(2023, 2, 11, 15, 4, 0, TimeSpan.Zero);
1895 var date2 = new DateTimeOffset(2023, 2, 11, 15, 6, 0, TimeSpan.Zero);
1928 var date1 = new DateTimeOffset(2023, 2, 11, 15, 4, 0, TimeSpan.Zero);
1929 var date2 = new DateTimeOffset(2023, 2, 11, 16, 5, 0, TimeSpan.FromHours(1));
1943 var date1 = new DateTimeOffset(2023, 2, 11, 15, 4, 0, TimeSpan.Zero);
1944 var date2 = new DateTimeOffset(2023, 2, 11, 15, 4, 0, TimeSpan.FromHours(1));
EquivalenceAssertsTests.cs (4)
1503 var expected = new DateTimeOffset(2022, 12, 1, 1, 3, 1, TimeSpan.Zero);
1504 var actual = new DateTimeOffset(2022, 12, 1, 1, 3, 1, TimeSpan.Zero);
1512 var expected = new DateTimeOffset(2022, 12, 1, 1, 3, 1, TimeSpan.Zero);
1513 var actual = new DateTimeOffset(2011, 9, 13, 18, 22, 0, TimeSpan.Zero);
Microsoft.Extensions.AI.Abstractions.Tests (14)
ChatCompletion\ChatResponseTests.cs (6)
61response.CreatedAt = new DateTimeOffset(2022, 1, 1, 0, 0, 0, TimeSpan.Zero);
62Assert.Equal(new DateTimeOffset(2022, 1, 1, 0, 0, 0, TimeSpan.Zero), response.CreatedAt);
91CreatedAt = new DateTimeOffset(2022, 1, 1, 0, 0, 0, TimeSpan.Zero),
108Assert.Equal(new DateTimeOffset(2022, 1, 1, 0, 0, 0, TimeSpan.Zero), result.CreatedAt);
135CreatedAt = new DateTimeOffset(2024, 11, 10, 9, 20, 0, TimeSpan.Zero),
148Assert.Equal(new DateTimeOffset(2024, 11, 10, 9, 20, 0, TimeSpan.Zero), update0.CreatedAt);
ChatCompletion\ChatResponseUpdateExtensionsTests.cs (3)
31new(ChatRole.Assistant, "Hello") { ResponseId = "someResponse", MessageId = "12345", CreatedAt = new DateTimeOffset(1, 2, 3, 4, 5, 6, TimeSpan.Zero), ModelId = "model123" },
33new(null, "world!") { CreatedAt = new DateTimeOffset(2, 2, 3, 4, 5, 6, TimeSpan.Zero), ConversationId = "123", AdditionalProperties = new() { ["c"] = "d" } },
49Assert.Equal(new DateTimeOffset(2, 2, 3, 4, 5, 6, TimeSpan.Zero), response.CreatedAt);
ChatCompletion\ChatResponseUpdateTests.cs (4)
76update.CreatedAt = new DateTimeOffset(2022, 1, 1, 0, 0, 0, TimeSpan.Zero);
77Assert.Equal(new DateTimeOffset(2022, 1, 1, 0, 0, 0, TimeSpan.Zero), update.CreatedAt);
130CreatedAt = new DateTimeOffset(2022, 1, 1, 0, 0, 0, TimeSpan.Zero),
161Assert.Equal(new DateTimeOffset(2022, 1, 1, 0, 0, 0, TimeSpan.Zero), result.CreatedAt);
Microsoft.Extensions.Caching.Memory (1)
Microsoft.Extensions.Caching.SqlServer.Tests (2)
Microsoft.Extensions.Caching.StackExchangeRedis (2)
Microsoft.Extensions.Logging.AzureAppServices (1)
Microsoft.Extensions.TimeProvider.Testing (1)
Microsoft.Extensions.TimeProvider.Testing.Tests (10)
FakeTimeProviderTests.cs (10)
46var nowOffset = new DateTimeOffset(2000, 1, 1, 0, 0, 0, 0, TimeSpan.Zero);
52Assert.Equal(nowOffset, new DateTimeOffset(timestamp1, TimeSpan.Zero));
53Assert.Equal(nowOffset, new DateTimeOffset(timestamp2, TimeSpan.Zero));
60var nowOffset = new DateTimeOffset(2000, 1, 1, 0, 0, 0, 0, TimeSpan.Zero);
69Assert.Equal(nowOffset, new DateTimeOffset(timestamp1, TimeSpan.Zero));
70Assert.Equal(nowOffset.AddMilliseconds(msToElapse), new DateTimeOffset(timestamp2, TimeSpan.Zero));
103var timeProvider = new FakeTimeProvider(new DateTimeOffset(2001, 2, 3, 4, 5, 6, TimeSpan.Zero));
162var timeProvider = new FakeTimeProvider(new DateTimeOffset(2001, 2, 3, 4, 5, 6, TimeSpan.Zero));
186var timeProvider = new FakeTimeProvider(new DateTimeOffset(2001, 2, 3, 4, 5, 6, TimeSpan.Zero));
280var dto = new DateTimeOffset(new DateTime(2022, 1, 2, 3, 4, 5, 6), TimeSpan.Zero);
Microsoft.Maui.Essentials (1)
Microsoft.ML.Data (1)
Microsoft.ML.Tests (8)
Scenarios\Api\TestApi.cs (8)
423DateTimeOffsetStrat = new DateTimeOffset(2002, 2, 23, 3, 30, 0, new TimeSpan(1, 0, 0)), TimeSpanStrat = new TimeSpan(2, 0, 0)
427DateTimeOffsetStrat = new DateTimeOffset(2002, 2, 23, 3, 30, 0, new TimeSpan(2, 0, 0)), TimeSpanStrat = new TimeSpan(2, 0, 10)
431DateTimeOffsetStrat = new DateTimeOffset(2002, 2, 23, 3, 30, 0, new TimeSpan(1, 0, 0)), TimeSpanStrat = new TimeSpan(2, 0, 10)
435DateTimeOffsetStrat = new DateTimeOffset(2002, 2, 23, 3, 30, 0, new TimeSpan(2, 0, 0)), TimeSpanStrat = new TimeSpan(2, 0, 0)
439DateTimeOffsetStrat = new DateTimeOffset(2002, 2, 23, 3, 30, 0, new TimeSpan(3, 0, 0)), TimeSpanStrat = new TimeSpan(2, 0, 20)
443DateTimeOffsetStrat = new DateTimeOffset(2002, 2, 23, 3, 30, 0, new TimeSpan(4, 0, 0)), TimeSpanStrat = new TimeSpan(2, 0, 30)
447DateTimeOffsetStrat = new DateTimeOffset(2002, 2, 23, 3, 30, 0, new TimeSpan(3, 0, 0)), TimeSpanStrat = new TimeSpan(2, 0, 30)
451DateTimeOffsetStrat = new DateTimeOffset(2002, 2, 23, 3, 30, 0, new TimeSpan(4, 0, 0)), TimeSpanStrat = new TimeSpan(2, 0, 20)
Microsoft.Net.Http.Headers.Tests (28)
RazorWebSite (2)
Shared.Tests (1)
System.Data.Common (1)
System.Formats.Asn1 (3)
System.Formats.Tar (2)
System.IO.Compression (1)
System.IO.IsolatedStorage (6)
System\IO\IsolatedStorage\IsolatedStorageFile.cs (6)
243return new DateTimeOffset(File.GetCreationTime(GetFullPath(path)));
247return new DateTimeOffset(1601, 1, 1, 0, 0, 0, TimeSpan.Zero).ToLocalTime();
259return new DateTimeOffset(File.GetLastAccessTime(GetFullPath(path)));
263return new DateTimeOffset(1601, 1, 1, 0, 0, 0, TimeSpan.Zero).ToLocalTime();
275return new DateTimeOffset(File.GetLastWriteTime(GetFullPath(path)));
279return new DateTimeOffset(1601, 1, 1, 0, 0, 0, TimeSpan.Zero).ToLocalTime();
System.Net.Mail (1)
System.Private.CoreLib (21)
src\libraries\System.Private.CoreLib\src\System\DateTimeOffset.cs (13)
62public static readonly DateTimeOffset MaxValue = new DateTimeOffset(0, DateTime.CreateUnchecked(DateTime.MaxTicks));
63public static readonly DateTimeOffset UnixEpoch = new DateTimeOffset(0, DateTime.CreateUnchecked(DateTime.UnixEpochTicks));
85private static DateTimeOffset CreateValidateOffset(DateTime dateTime, TimeSpan offset) => new DateTimeOffset(ValidateOffset(offset), ValidateDate(dateTime, offset));
159DateTimeOffset value = new(year, month, day, hour, minute, 59, offset);
194DateTimeOffset value = new DateTimeOffset(year, month, day, hour, minute, 59, millisecond, calendar, offset);
219/// the <see cref="DateTimeOffset(int, int, int, int, int, int, int, int, Calendar, TimeSpan)"/> constructor.
276/// the <see cref="DateTimeOffset(int, int, int, int, int, int, int, int, Calendar, TimeSpan)"/> constructor.
332public static DateTimeOffset UtcNow => new DateTimeOffset(0, DateTime.SpecifyKind(DateTime.UtcNow, DateTimeKind.Unspecified));
533private DateTimeOffset Add(DateTime dateTime) => new DateTimeOffset(_offsetMinutes, ValidateDate(dateTime, Offset));
594return new DateTimeOffset(0, DateTime.CreateUnchecked(ticks));
608return new DateTimeOffset(0, DateTime.CreateUnchecked(ticks));
811public DateTimeOffset ToUniversalTime() => new DateTimeOffset(0, _dateTime);
977new DateTimeOffset(dateTime);
System.Private.DataContractSerialization (2)
System.Private.Windows.Core (4)
System.Private.Xml (6)
System.Text.Json (2)
System.Xaml.Tests (3)
System\Xaml\Replacements\DateTimeOffsetConverter2Tests.cs (3)
31DateTimeOffset dateTimeOffset = new DateTimeOffset(2018, 12, 9, 1, 2, 3, 4, TimeSpan.FromMinutes(10));
71yield return new object?[] { new DateTimeOffset(2018, 12, 9, 1, 2, 3, 4, TimeSpan.FromMinutes(10)), new CultureInfo("en-US") };
86var dateTimeOffset = new DateTimeOffset(2018, 12, 9, 1, 2, 3, 4, TimeSpan.FromMinutes(10));
3344 references to DateTimeOffset
aspire (7)
Aspire.Azure.Npgsql.EntityFrameworkCore.PostgreSQL.Tests (1)
Aspire.Azure.Npgsql.Tests (1)
Aspire.Azure.Security.KeyVault.Tests (1)
Aspire.Cli.Tests (2)
Aspire.Confluent.Kafka (32)
Aspire.Dashboard (64)
Components\Controls\Chart\ChartBase.cs (31)
27private DateTimeOffset _lastUpdateTime;
28private DateTimeOffset _currentDataStartTime;
86var inProgressDataTime = PauseManager.AreMetricsPaused(out var pausedAt) ? pausedAt.Value : GetCurrentDataTime();
124private (List<ChartTrace> Y, List<DateTimeOffset> X, List<ChartExemplar> Exemplars) CalculateHistogramValues(List<DimensionScope> dimensions, int pointCount, bool tickUpdate, DateTimeOffset inProgressDataTime, string yLabel)
133var xValues = new List<DateTimeOffset>();
135var startDate = _currentDataStartTime;
136DateTimeOffset? firstPointEndTime = null;
137DateTimeOffset? lastPointStartTime = null;
143var start = CalcOffset(pointIndex, startDate, pointDuration);
144var end = CalcOffset(pointIndex - 1, startDate, pointDuration);
201private string FormatTooltip(string name, double yValue, DateTimeOffset xValue)
216internal bool TryCalculateHistogramPoints(List<DimensionScope> dimensions, DateTimeOffset start, DateTimeOffset end, Dictionary<int, ChartTrace> traces, List<ChartExemplar> exemplars)
324var exemplarStart = TimeProvider.ToLocalDateTimeOffset(exemplar.Start);
377private (List<ChartTrace> Y, List<DateTimeOffset> X, List<ChartExemplar> Exemplars) CalculateChartValues(List<DimensionScope> dimensions, int pointCount, bool tickUpdate, DateTimeOffset inProgressDataTime, string yLabel)
381var xValues = new List<DateTimeOffset>();
383var startDate = _currentDataStartTime;
384DateTimeOffset? firstPointEndTime = null;
390var start = CalcOffset(pointIndex, startDate, pointDuration);
391var end = CalcOffset(pointIndex - 1, startDate, pointDuration);
437private bool TryCalculatePoint(List<DimensionScope> dimensions, DateTimeOffset start, DateTimeOffset end, List<ChartExemplar> exemplars, out double pointValue)
479private static DateTimeOffset CalcOffset(int pointIndex, DateTimeOffset now, TimeSpan pointDuration)
484private async Task UpdateChartAsync(bool tickUpdate, DateTimeOffset inProgressDataTime)
498List<DateTimeOffset> xValues;
519private DateTimeOffset GetCurrentDataTime()
529protected abstract Task OnChartUpdatedAsync(List<ChartTrace> traces, List<DateTimeOffset> xValues, List<ChartExemplar> exemplars, bool tickUpdate, DateTimeOffset inProgressDataTime, CancellationToken cancellationToken);
Components\Controls\Chart\MetricTable.razor.cs (13)
21private SortedList<DateTimeOffset, MetricViewBase> _metrics = [];
28private DateTimeOffset? _lastUpdate;
40protected override async Task OnChartUpdatedAsync(List<ChartTrace> traces, List<DateTimeOffset> xValues, List<ChartExemplar> exemplars, bool tickUpdate, DateTimeOffset inProgressDataTime, CancellationToken cancellationToken)
114private SortedList<DateTimeOffset, MetricViewBase> UpdateMetrics(out ISet<DateTimeOffset> addedXValues, List<ChartTrace> traces, List<DateTimeOffset> xValues, List<ChartExemplar> exemplars)
116var newMetrics = new SortedList<DateTimeOffset, MetricViewBase>();
122var xValue = xValues[i];
206var endTime = (i != newMetrics.Count - 1) ? current.DateTime : (DateTimeOffset?)null;
207var startTime = (i > 0) ? newMetrics.GetKeyAtIndex(i - 1) : (DateTimeOffset?)null;
215var latestCurrentMetric = _metrics.Keys.OfType<DateTimeOffset?>().LastOrDefault();
282public required DateTimeOffset DateTime { get; set; }
Components\Controls\Chart\PlotlyChart.razor.cs (9)
41private string FormatTooltip(string title, double yValue, DateTimeOffset xValue)
55protected override async Task OnChartUpdatedAsync(List<ChartTrace> traces, List<DateTimeOffset> xValues, List<ChartExemplar> exemplars, bool tickUpdate, DateTimeOffset inProgressDataTime, CancellationToken cancellationToken)
107private PlotlyTrace CalculateExemplarsTrace(List<DateTimeOffset> xValues, List<ChartExemplar> exemplars)
120var start = i > 0 ? xValues[i - 1] : (DateTimeOffset?)null;
121var end = i < xValues.Count ? xValues[i] : (DateTimeOffset?)null;
149X = new List<DateTimeOffset>(),
228private readonly record struct ExemplarGroupKey(DateTimeOffset? Start, DateTimeOffset? End);
Aspire.Dashboard.Components.Tests (13)
Aspire.Dashboard.Tests (13)
Aspire.Hosting (9)
Aspire.Hosting.Azure.Tests (18)
Aspire.Hosting.Testing.Tests (9)
Aspire.Hosting.Tests (21)
VersionChecking\VersionCheckServiceTests.cs (6)
68var currentDate = new DateTimeOffset(2000, 12, 29, 20, 59, 59, TimeSpan.Zero);
69var lastCheckDate = currentDate.AddMinutes(-1);
103var currentDate = new DateTimeOffset(2000, 12, 29, 20, 59, 59, TimeSpan.Zero);
104var lastCheckDate = currentDate.AddMinutes(-1);
210public DateTimeOffset UtcNow { get; set; } = new DateTimeOffset(2000, 12, 29, 20, 59, 59, TimeSpan.Zero);
212public override DateTimeOffset GetUtcNow()
Aspire.Playground.Tests (8)
AzureAppServicesHostingStartupSample (1)
AzureAppServicesSample (1)
AzureSearch.ApiService (1)
CdkSample.ApiService (3)
ConfigurationSchemaGenerator (1)
dotnet-dev-certs (11)
dotnet-svcutil.xmlserializer (1)
dotnet-svcutil-lib (170)
FrameworkFork\Microsoft.Xml\Xml\BinaryXml\SqlUtils.cs (14)
946public static DateTimeOffset XsdKatmaiDateToDateTimeOffset(byte[] data, int offset)
949return (DateTimeOffset)XsdKatmaiDateToDateTime(data, offset);
952public static DateTimeOffset XsdKatmaiDateTimeToDateTimeOffset(byte[] data, int offset)
955return (DateTimeOffset)XsdKatmaiDateTimeToDateTime(data, offset);
958public static DateTimeOffset XsdKatmaiTimeToDateTimeOffset(byte[] data, int offset)
961return (DateTimeOffset)XsdKatmaiTimeToDateTime(data, offset);
964public static DateTimeOffset XsdKatmaiDateOffsetToDateTimeOffset(byte[] data, int offset)
970public static DateTimeOffset XsdKatmaiDateTimeOffsetToDateTimeOffset(byte[] data, int offset)
977DateTimeOffset dto = new DateTimeOffset(dateTicks + timeTicks + zoneTicks, new TimeSpan(zoneTicks));
981public static DateTimeOffset XsdKatmaiTimeOffsetToDateTimeOffset(byte[] data, int offset)
1016DateTimeOffset dto = XsdKatmaiDateOffsetToDateTimeOffset(data, offset);
1025DateTimeOffset dto = XsdKatmaiDateTimeOffsetToDateTimeOffset(data, offset);
1036DateTimeOffset dto = XsdKatmaiTimeOffsetToDateTimeOffset(data, offset);
1091private static int GetFractions(DateTimeOffset dt)
FrameworkFork\Microsoft.Xml\Xml\schema\XmlValueConverter.cs (122)
169public abstract bool ToBoolean(DateTimeOffset value);
180public abstract int ToInt32(DateTimeOffset value);
191public abstract long ToInt64(DateTimeOffset value);
202public abstract decimal ToDecimal(DateTimeOffset value);
213public abstract double ToDouble(DateTimeOffset value);
224public abstract float ToSingle(DateTimeOffset value);
235public abstract DateTime ToDateTime(DateTimeOffset value);
239public abstract DateTimeOffset ToDateTimeOffset(bool value);
240public abstract DateTimeOffset ToDateTimeOffset(int value);
241public abstract DateTimeOffset ToDateTimeOffset(long value);
242public abstract DateTimeOffset ToDateTimeOffset(decimal value);
243public abstract DateTimeOffset ToDateTimeOffset(float value);
244public abstract DateTimeOffset ToDateTimeOffset(double value);
245public abstract DateTimeOffset ToDateTimeOffset(DateTime value);
246public abstract DateTimeOffset ToDateTimeOffset(DateTimeOffset value);
247public abstract DateTimeOffset ToDateTimeOffset(string value);
248public abstract DateTimeOffset ToDateTimeOffset(object value);
257public abstract string ToString(DateTimeOffset value);
270public abstract object ChangeType(DateTimeOffset value, Type destinationType);
366protected static readonly Type DateTimeOffsetType = typeof(DateTimeOffset);
376public override bool ToBoolean(DateTimeOffset value) { return (bool)ChangeType((object)value, BooleanType, null); }
387public override DateTime ToDateTime(DateTimeOffset value) { return (DateTime)ChangeType((object)value, DateTimeType, null); }
396public override DateTimeOffset ToDateTimeOffset(bool value) { return (DateTimeOffset)ChangeType((object)value, DateTimeOffsetType, null); }
397public override DateTimeOffset ToDateTimeOffset(DateTime value) { return (DateTimeOffset)ChangeType((object)value, DateTimeOffsetType, null); }
398public override DateTimeOffset ToDateTimeOffset(DateTimeOffset value) { return (DateTimeOffset)ChangeType((object)value, DateTimeOffsetType, null); }
399public override DateTimeOffset ToDateTimeOffset(decimal value) { return (DateTimeOffset)ChangeType((object)value, DateTimeOffsetType, null); }
400public override DateTimeOffset ToDateTimeOffset(double value) { return (DateTimeOffset)ChangeType((object)value, DateTimeOffsetType, null); }
401public override DateTimeOffset ToDateTimeOffset(int value) { return (DateTimeOffset)ChangeType((object)value, DateTimeOffsetType, null); }
402public override DateTimeOffset ToDateTimeOffset(long value) { return (DateTimeOffset)ChangeType((object)value, DateTimeOffsetType, null); }
403public override DateTimeOffset ToDateTimeOffset(float value) { return (DateTimeOffset)ChangeType((object)value, DateTimeOffsetType, null); }
404public override DateTimeOffset ToDateTimeOffset(string value) { return (DateTimeOffset)ChangeType((object)value, DateTimeOffsetType, null); }
405public override DateTimeOffset ToDateTimeOffset(object value) { return (DateTimeOffset)ChangeType((object)value, DateTimeOffsetType, null); }
409public override decimal ToDecimal(DateTimeOffset value) { return (decimal)ChangeType((object)value, DecimalType, null); }
420public override double ToDouble(DateTimeOffset value) { return (double)ChangeType((object)value, DoubleType, null); }
431public override int ToInt32(DateTimeOffset value) { return (int)ChangeType((object)value, Int32Type, null); }
442public override long ToInt64(DateTimeOffset value) { return (long)ChangeType((object)value, Int64Type, null); }
453public override float ToSingle(DateTimeOffset value) { return (float)ChangeType((object)value, SingleType, null); }
464public override string ToString(DateTimeOffset value) { return (string)ChangeType((object)value, StringType, null); }
477public override object ChangeType(DateTimeOffset value, Type destinationType) { return (object)ChangeType((object)value, destinationType, null); }
659protected static DateTimeOffset StringToDateOffset(string value)
661return (DateTimeOffset)(new XsdDateTime(value, XsdDateTimeFlags.Date));
664protected static DateTimeOffset StringToDateTimeOffset(string value)
666return (DateTimeOffset)(new XsdDateTime(value, XsdDateTimeFlags.DateTime));
669protected static DateTimeOffset StringToGDayOffset(string value)
671return (DateTimeOffset)(new XsdDateTime(value, XsdDateTimeFlags.GDay));
674protected static DateTimeOffset StringToGMonthOffset(string value)
676return (DateTimeOffset)(new XsdDateTime(value, XsdDateTimeFlags.GMonth));
679protected static DateTimeOffset StringToGMonthDayOffset(string value)
681return (DateTimeOffset)(new XsdDateTime(value, XsdDateTimeFlags.GMonthDay));
684protected static DateTimeOffset StringToGYearOffset(string value)
686return (DateTimeOffset)(new XsdDateTime(value, XsdDateTimeFlags.GYear));
689protected static DateTimeOffset StringToGYearMonthOffset(string value)
691return (DateTimeOffset)(new XsdDateTime(value, XsdDateTimeFlags.GYearMonth));
740protected static DateTimeOffset StringToTimeOffset(string value)
742return (DateTimeOffset)(new XsdDateTime(value, XsdDateTimeFlags.Time));
811protected static string DateOffsetToString(DateTimeOffset value)
816protected static string DateTimeOffsetToString(DateTimeOffset value)
821protected static string GDayOffsetToString(DateTimeOffset value)
826protected static string GMonthOffsetToString(DateTimeOffset value)
831protected static string GMonthDayOffsetToString(DateTimeOffset value)
836protected static string GYearOffsetToString(DateTimeOffset value)
841protected static string GYearMonthOffsetToString(DateTimeOffset value)
865protected static string TimeOffsetToString(DateTimeOffset value)
880internal static DateTime DateTimeOffsetToDateTime(DateTimeOffset value)
962protected static DateTimeOffset UntypedAtomicToDateTimeOffset(string value)
964return (DateTimeOffset)(new XsdDateTime(value, XsdDateTimeFlags.AllXsd));
1564public override DateTime ToDateTime(DateTimeOffset value)
1592if (sourceType == DateTimeOffsetType) return this.ToDateTime((DateTimeOffset)value);
1603public override DateTimeOffset ToDateTimeOffset(DateTime value)
1608public override DateTimeOffset ToDateTimeOffset(DateTimeOffset value)
1610return ((DateTimeOffset)value);
1613public override DateTimeOffset ToDateTimeOffset(string value)
1630public override DateTimeOffset ToDateTimeOffset(object value)
1637if (sourceType == DateTimeOffsetType) return ((DateTimeOffset)value);
1639if (sourceType == XmlAtomicValueType) return (DateTimeOffset)((XmlAtomicValue)value).ValueAsDateTime;
1641return (DateTimeOffset)ChangeListType(value, DateTimeOffsetType, null);
1698public override string ToString(DateTimeOffset value)
1702case XmlTypeCode.Date: return DateOffsetToString((DateTimeOffset)value);
1703case XmlTypeCode.Time: return TimeOffsetToString((DateTimeOffset)value);
1704case XmlTypeCode.GDay: return GDayOffsetToString((DateTimeOffset)value);
1705case XmlTypeCode.GMonth: return GMonthOffsetToString((DateTimeOffset)value);
1706case XmlTypeCode.GMonthDay: return GMonthDayOffsetToString((DateTimeOffset)value);
1707case XmlTypeCode.GYear: return GYearOffsetToString((DateTimeOffset)value);
1708case XmlTypeCode.GYearMonth: return GYearMonthOffsetToString((DateTimeOffset)value);
1710return DateTimeOffsetToString((DateTimeOffset)value);
1726if (sourceType == DateTimeOffsetType) return this.ToString((DateTimeOffset)value);
1752public override object ChangeType(DateTimeOffset value, Type destinationType)
1757if (destinationType == DateTimeType) return this.ToDateTime((DateTimeOffset)value);
1758if (destinationType == DateTimeOffsetType) return ((DateTimeOffset)value);
1759if (destinationType == StringType) return this.ToString((DateTimeOffset)value);
1760if (destinationType == XmlAtomicValueType) return (new XmlAtomicValue(SchemaType, (DateTimeOffset)value));
1761if (destinationType == XPathItemType) return (new XmlAtomicValue(SchemaType, (DateTimeOffset)value));
1795if (sourceType == DateTimeOffsetType) return (new XmlAtomicValue(SchemaType, (DateTimeOffset)value));
1802if (sourceType == DateTimeOffsetType) return (new XmlAtomicValue(SchemaType, (DateTimeOffset)value));
2463public override DateTimeOffset ToDateTimeOffset(string value)
2470public override DateTimeOffset ToDateTimeOffset(object value)
2478return (DateTimeOffset)ChangeTypeWildcardDestination(value, DateTimeOffsetType, null);
2603public override string ToString(DateTimeOffset value)
2605return DateTimeOffsetToString((DateTimeOffset)value);
2643if (sourceType == DateTimeOffsetType) return DateTimeOffsetToString((DateTimeOffset)value);
2688public override object ChangeType(DateTimeOffset value, Type destinationType)
2693if (destinationType == StringType) return DateTimeOffsetToString((DateTimeOffset)value);
3087public override DateTimeOffset ToDateTimeOffset(object value)
3093if (sourceType == XmlAtomicValueType) return (DateTimeOffset)((XmlAtomicValue)value).ValueAs(DateTimeOffsetType);
3095return (DateTimeOffset)ChangeTypeWildcardDestination(value, DateTimeOffsetType, null);
3210public override object ChangeType(DateTimeOffset value, Type destinationType)
3215if (destinationType == XmlAtomicValueType) return (new XmlAtomicValue(XmlSchemaType.GetBuiltInSimpleType(XmlTypeCode.DateTime), (DateTimeOffset)value));
3328if (sourceType == DateTimeOffsetType) return (new XmlAtomicValue(XmlSchemaType.GetBuiltInSimpleType(XmlTypeCode.DateTime), (DateTimeOffset)value));
3518if (itemTypeDst == DateTimeOffsetType) return ToArray<DateTimeOffset>(value, nsResolver);
dotnet-user-jwts (3)
FilesWebSite (2)
Controllers\DownloadFilesController.cs (2)
30var lastModified = new DateTimeOffset(year: 1999, month: 11, day: 04, hour: 3, minute: 0, second: 0, offset: new TimeSpan(0));
44var lastModified = new DateTimeOffset(year: 1999, month: 11, day: 04, hour: 3, minute: 0, second: 0, offset: new TimeSpan(0));
HtmlGenerationWebSite (1)
HttpAbstractions.SampleApp (1)
HttpStress (2)
Identity.DefaultUI.WebSite (8)
Identity.ExternalClaims (3)
IdentitySample.DefaultUI (3)
IdentitySample.Mvc (3)
IdentitySample.PasskeyConformance (2)
IdentitySample.PasskeyUI (2)
IIS.FunctionalTests (4)
IIS.LongTests (4)
IIS.NewHandler.FunctionalTests (4)
IIS.NewShim.FunctionalTests (4)
IIS.ShadowCopy.Tests (4)
IISExpress.FunctionalTests (4)
IISSample (1)
InMemory.FunctionalTests (22)
Interop.FunctionalTests (2)
KeyManagementSample (3)
KeyManagementSimulator (14)
Microsoft.Arcade.Common (1)
Microsoft.AspNetCore.Authentication (4)
Microsoft.AspNetCore.Authentication.Abstractions (8)
Microsoft.AspNetCore.Authentication.BearerToken (2)
Microsoft.AspNetCore.Authentication.Certificate (2)
Microsoft.AspNetCore.Authentication.Cookies (9)
Microsoft.AspNetCore.Authentication.Core.Test (3)
Microsoft.AspNetCore.Authentication.OAuth (1)
Microsoft.AspNetCore.Authentication.OpenIdConnect (2)
Microsoft.AspNetCore.Authentication.Test (10)
Microsoft.AspNetCore.Authentication.Twitter (2)
Microsoft.AspNetCore.Authorization.Policy (1)
Microsoft.AspNetCore.Authorization.Test (2)
AuthorizationMiddlewareTests.cs (2)
823var firstExpiration = new DateTimeOffset(2021, 5, 12, 2, 3, 4, TimeSpan.Zero);
824var secondExpiration = new DateTimeOffset(2021, 5, 11, 2, 3, 4, TimeSpan.Zero);
Microsoft.AspNetCore.Components (64)
BindConverter.cs (39)
332/// <param name="format">The format to use. Provided to <see cref="DateTimeOffset.ToString(string, IFormatProvider)"/>.</param>
412public static string FormatValue(DateTimeOffset value, CultureInfo? culture = null) => FormatDateTimeOffsetValueCore(value, format: null, culture);
418/// <param name="format">The format to use. Provided to <see cref="DateTimeOffset.ToString(string, IFormatProvider)"/>.</param>
424public static string FormatValue(DateTimeOffset value, string format, CultureInfo? culture = null) => FormatDateTimeOffsetValueCore(value, format, culture);
426private static string FormatDateTimeOffsetValueCore(DateTimeOffset value, string? format, CultureInfo? culture)
436private static string FormatDateTimeOffsetValueCore(DateTimeOffset value, CultureInfo? culture)
450public static string? FormatValue(DateTimeOffset? value, CultureInfo? culture = null) => FormatNullableDateTimeOffsetValueCore(value, format: null, culture);
456/// <param name="format">The format to use. Provided to <see cref="DateTimeOffset.ToString(string, IFormatProvider)"/>.</param>
462public static string? FormatValue(DateTimeOffset? value, string format, CultureInfo? culture = null) => FormatNullableDateTimeOffsetValueCore(value, format, culture);
464private static string? FormatNullableDateTimeOffsetValueCore(DateTimeOffset? value, string? format, CultureInfo? culture)
479private static string? FormatNullableDateTimeOffsetValueCore(DateTimeOffset? value, CultureInfo? culture)
1280/// Attempts to convert a value to a <see cref="System.DateTimeOffset"/>.
1286public static bool TryConvertToDateTimeOffset(object? obj, CultureInfo? culture, out DateTimeOffset value)
1292/// Attempts to convert a value to a <see cref="System.DateTimeOffset"/>.
1299public static bool TryConvertToDateTimeOffset(object? obj, CultureInfo? culture, string format, out DateTimeOffset value)
1305/// Attempts to convert a value to a nullable <see cref="System.DateTimeOffset"/>.
1311public static bool TryConvertToNullableDateTimeOffset(object? obj, CultureInfo? culture, out DateTimeOffset? value)
1317/// Attempts to convert a value to a nullable <see cref="System.DateTimeOffset"/>.
1324public static bool TryConvertToNullableDateTimeOffset(object? obj, CultureInfo? culture, string format, out DateTimeOffset? value)
1329internal static BindParser<DateTimeOffset> ConvertToDateTimeOffset = ConvertToDateTimeOffsetCore;
1330internal static BindParserWithFormat<DateTimeOffset> ConvertToDateTimeOffsetWithFormat = ConvertToDateTimeOffsetCore;
1331internal static BindParser<DateTimeOffset?> ConvertToNullableDateTimeOffset = ConvertToNullableDateTimeOffsetCore;
1332internal static BindParserWithFormat<DateTimeOffset?> ConvertToNullableDateTimeOffsetWithFormat = ConvertToNullableDateTimeOffsetCore;
1334private static bool ConvertToDateTimeOffsetCore(object? obj, CultureInfo? culture, out DateTimeOffset value)
1339private static bool ConvertToDateTimeOffsetCore(object? obj, CultureInfo? culture, string? format, out DateTimeOffset value)
1348if (format != null && DateTimeOffset.TryParseExact(text, format, culture ?? CultureInfo.CurrentCulture, DateTimeStyles.None, out var converted))
1353else if (format == null && DateTimeOffset.TryParse(text, culture ?? CultureInfo.CurrentCulture, DateTimeStyles.None, out converted))
1363private static bool ConvertToNullableDateTimeOffsetCore(object? obj, CultureInfo? culture, out DateTimeOffset? value)
1368private static bool ConvertToNullableDateTimeOffsetCore(object? obj, CultureInfo? culture, string? format, out DateTimeOffset? value)
1377if (format != null && DateTimeOffset.TryParseExact(text, format, culture ?? CultureInfo.CurrentCulture, DateTimeStyles.None, out var converted))
1382else if (format == null && DateTimeOffset.TryParse(text, culture ?? CultureInfo.CurrentCulture, DateTimeStyles.None, out converted))
1758else if (typeof(T) == typeof(DateTimeOffset))
1760formatter = (BindFormatter<DateTimeOffset>)FormatDateTimeOffsetValueCore;
1762else if (typeof(T) == typeof(DateTimeOffset?))
1764formatter = (BindFormatter<DateTimeOffset?>)FormatNullableDateTimeOffsetValueCore;
1949else if (typeof(T) == typeof(DateTimeOffset))
1953else if (typeof(T) == typeof(DateTimeOffset?))
EventCallbackFactoryBinderExtensions.cs (24)
806Action<DateTimeOffset> setter,
807DateTimeOffset existingValue,
810return CreateBinderCore<DateTimeOffset>(factory, receiver, setter, culture, ConvertToDateTimeOffset);
826Func<DateTimeOffset, Task> setter,
827DateTimeOffset existingValue,
830return CreateBinderCoreAsync<DateTimeOffset>(factory, receiver, setter, culture, ConvertToDateTimeOffset);
847Action<DateTimeOffset> setter,
848DateTimeOffset existingValue,
852return CreateBinderCore<DateTimeOffset>(factory, receiver, setter, culture, format, ConvertToDateTimeOffsetWithFormat);
869Func<DateTimeOffset, Task> setter,
870DateTimeOffset existingValue,
874return CreateBinderCoreAsync<DateTimeOffset>(factory, receiver, setter, culture, format, ConvertToDateTimeOffsetWithFormat);
890Action<DateTimeOffset?> setter,
891DateTimeOffset? existingValue,
894return CreateBinderCore<DateTimeOffset?>(factory, receiver, setter, culture, ConvertToNullableDateTimeOffset);
910Func<DateTimeOffset?, Task> setter,
911DateTimeOffset? existingValue,
914return CreateBinderCoreAsync<DateTimeOffset?>(factory, receiver, setter, culture, ConvertToNullableDateTimeOffset);
931Action<DateTimeOffset?> setter,
932DateTimeOffset? existingValue,
936return CreateBinderCore<DateTimeOffset?>(factory, receiver, setter, culture, format, ConvertToNullableDateTimeOffsetWithFormat);
953Func<DateTimeOffset?, Task> setter,
954DateTimeOffset? existingValue,
958return CreateBinderCoreAsync<DateTimeOffset?>(factory, receiver, setter, culture, format, ConvertToNullableDateTimeOffsetWithFormat);
Microsoft.AspNetCore.Components.Endpoints (9)
Microsoft.AspNetCore.Components.Endpoints.Tests (7)
Binding\FormDataMapperTests.cs (4)
2126{ "4/20/2023 12:56:34 PM +02:00", typeof(DateTimeOffset?), new DateTimeOffset?(new DateTimeOffset(2023, 04, 20, 12, 56, 34, TimeSpan.FromHours(2)))},
2168{ typeof(DateTimeOffset?) },
2211{ "4/20/2023 12:56:34 PM +02:00", typeof(DateTimeOffset), new DateTimeOffset(2023, 04, 20, 12, 56, 34, TimeSpan.FromHours(2)) },
Microsoft.AspNetCore.Components.Server (4)
Microsoft.AspNetCore.Components.Server.Tests (1)
Microsoft.AspNetCore.Components.Tests (12)
Microsoft.AspNetCore.Components.Web (5)
Microsoft.AspNetCore.Components.WebView (4)
Microsoft.AspNetCore.Components.WebView.Test (2)
Microsoft.AspNetCore.CookiePolicy.Test (5)
Microsoft.AspNetCore.DataProtection (77)
KeyManagement\Key.cs (15)
37DateTimeOffset creationDate,
38DateTimeOffset activationDate,
39DateTimeOffset expirationDate,
59DateTimeOffset creationDate,
60DateTimeOffset activationDate,
61DateTimeOffset expirationDate,
79DateTimeOffset creationDate,
80DateTimeOffset activationDate,
81DateTimeOffset expirationDate,
97DateTimeOffset creationDate,
98DateTimeOffset activationDate,
99DateTimeOffset expirationDate,
116public DateTimeOffset ActivationDate { get; }
118public DateTimeOffset CreationDate { get; }
120public DateTimeOffset ExpirationDate { get; }
LoggingExtensions.cs (10)
44public static partial void UsingFallbackKeyWithExpirationAsDefaultKey(this ILogger logger, Guid keyId, DateTimeOffset expirationDate);
80public static partial void ConsideringKeyWithExpirationDateAsDefaultKey(this ILogger logger, Guid keyId, DateTimeOffset expirationDate);
98public static partial void FoundRevocationOfAllKeysCreatedPriorTo(this ILogger logger, DateTimeOffset revocationDate);
107public static partial void RevokingAllKeysAsOfForReason(this ILogger logger, DateTimeOffset revocationDate, string? reason);
146public static partial void RevokingKeyForReason(this ILogger logger, Guid keyId, DateTimeOffset revocationDate, string? reason);
215public static partial void CreatingKey(this ILogger logger, Guid keyId, DateTimeOffset creationDate, DateTimeOffset activationDate, DateTimeOffset expirationDate);
275public static partial void DateBasedRevocationSuperseded(this ILogger logger, DateTimeOffset olderDate, DateTimeOffset newerDate);
Microsoft.AspNetCore.DataProtection.Extensions (14)
Microsoft.AspNetCore.DataProtection.Extensions.Tests (33)
DataProtectionAdvancedExtensionsTests.cs (21)
37DateTimeOffset actualExpiration = default(DateTimeOffset);
39mockDataProtector.Setup(o => o.Protect(plaintextAsBytes, It.IsAny<DateTimeOffset>()))
40.Returns<byte[], DateTimeOffset>((_, exp) =>
47DateTimeOffset lowerBound = DateTimeOffset.UtcNow.AddHours(48);
49DateTimeOffset upperBound = DateTimeOffset.UtcNow.AddHours(48);
60DateTimeOffset actualExpiration = default(DateTimeOffset);
62mockDataProtector.Setup(o => o.Protect(new byte[] { 0x11, 0x22, 0x33 }, It.IsAny<DateTimeOffset>()))
63.Returns<byte[], DateTimeOffset>((_, exp) =>
70DateTimeOffset lowerBound = DateTimeOffset.UtcNow.AddHours(48);
72DateTimeOffset upperBound = DateTimeOffset.UtcNow.AddHours(48);
83var futureDate = DateTimeOffset.UtcNow.AddYears(1);
84var controlExpiration = futureDate;
89string unprotectedPayload = mockDataProtector.Object.Unprotect(SampleEncodedString, out var testExpiration);
98return DateTimeOffset.ParseExact(input, "u", CultureInfo.InvariantCulture).UtcDateTime;
TimeLimitedDataProtectorTests.cs (12)
23DateTimeOffset expiration = StringToDateTime("2000-01-01 00:00:00Z");
46DateTimeOffset expiration = StringToDateTime("2000-01-01 00:00:00Z");
69DateTimeOffset expectedExpiration = StringToDateTime("2000-01-01 00:00:00Z");
70DateTimeOffset now = StringToDateTime("1999-01-01 00:00:00Z");
81var retVal = timeLimitedProtector.UnprotectCore(new byte[] { 0x10, 0x11 }, now, out var actualExpiration);
93DateTimeOffset expectedExpiration = StringToDateTime("2000-01-01 00:00:00Z");
94DateTimeOffset now = StringToDateTime("2001-01-01 00:00:00Z");
106=> timeLimitedProtector.UnprotectCore(new byte[] { 0x10, 0x11 }, now, out var _));
127=> timeLimitedProtector.Unprotect(new byte[] { 0x10, 0x11 }, out var _));
144=> timeLimitedProtector.Unprotect(new byte[] { 0x10, 0x11 }, out var _));
166timeLimitedProtector.UnprotectCore(timeLimitedProtectedPayload, StringToDateTime("2010-01-01 00:00:00Z"), out var actualExpiration));
176return DateTimeOffset.ParseExact(input, "u", CultureInfo.InvariantCulture).UtcDateTime;
Microsoft.AspNetCore.DataProtection.Tests (193)
KeyManagement\DefaultKeyResolverTests.cs (28)
23var resolution = resolver.ResolveDefaultKeyPolicy(DateTimeOffset.Now, new IKey[0]);
256var now = ParseDateTimeOffset("2010-01-01 00:00:00Z");
258var creation1 = now - TimeSpan.FromHours(1);
259var creation2 = creation1 - TimeSpan.FromHours(1);
260var activation1 = creation1;
261var activation2 = creation2;
262var expiration1 = creation1 + TimeSpan.FromDays(90);
263var expiration2 = creation2 + TimeSpan.FromDays(90);
283var now = ParseDateTimeOffset("2010-01-01 00:00:00Z");
326var now = ParseDateTimeOffset("2010-01-01 00:00:00Z");
329var creation1 = now.AddDays(-3);
330var activation1 = creation1.AddDays(2);
331var expiration1 = creation1.AddDays(90);
335var creation2 = creation1.AddHours(1);
336var activation2 = activation1.AddHours(1);
337var expiration2 = expiration1.AddHours(1);
403var now = ParseDateTimeOffset("2010-01-01 00:00:00Z");
405var creation = now.AddDays(-3);
406var activation = creation.AddDays(2);
407var expiration = creation.AddDays(90);
455return CreateKey(ParseDateTimeOffset(activationDate), ParseDateTimeOffset(expirationDate), creationDate == null ? (DateTimeOffset?)null : ParseDateTimeOffset(creationDate), isRevoked, createEncryptorThrows);
458private static IKey CreateKey(DateTimeOffset activationDate, DateTimeOffset expirationDate, DateTimeOffset? creationDate = null, bool isRevoked = false, bool createEncryptorThrows = false)
462mockKey.Setup(o => o.CreationDate).Returns(creationDate ?? DateTimeOffset.MinValue);
478private static DateTimeOffset ParseDateTimeOffset(string dto)
480return DateTimeOffset.ParseExact(dto, "u", CultureInfo.InvariantCulture);
488return resolver.ResolveDefaultKeyPolicy(DateTimeOffset.ParseExact(now, "u", CultureInfo.InvariantCulture), (IEnumerable<IKey>)allKeys);
KeyManagement\KeyRingBasedDataProtectorTests.cs (44)
209Key key = new Key(Guid.Empty, DateTimeOffset.Now, DateTimeOffset.Now, DateTimeOffset.Now, mockDescriptor.Object, new[] { mockEncryptorFactory.Object });
227return DateTimeOffset.ParseExact(input, "u", CultureInfo.InvariantCulture).UtcDateTime;
262Key key = new Key(Guid.Empty, DateTimeOffset.Now, DateTimeOffset.Now, DateTimeOffset.Now, mockDescriptor.Object, new[] { mockEncryptorFactory.Object });
263var keyRing = new CacheableKeyRing(CancellationToken.None, DateTimeOffset.MaxValue, key, new[] { key });
293Key key = new Key(Guid.Empty, DateTimeOffset.Now, DateTimeOffset.Now, DateTimeOffset.Now, mockDescriptor.Object, new[] { mockEncryptorFactory.Object });
294var keyRing = new CacheableKeyRing(CancellationToken.None, DateTimeOffset.MaxValue, key, new[] { key });
297Key key2 = new Key(notFoundKeyId, DateTimeOffset.Now, DateTimeOffset.Now, DateTimeOffset.Now, mockDescriptor.Object, new[] { mockEncryptorFactory.Object });
298var keyRing2 = new CacheableKeyRing(CancellationToken.None, DateTimeOffset.MaxValue, key, new[] { key2 });
329Key key = new Key(Guid.Empty, DateTimeOffset.Now, DateTimeOffset.Now, DateTimeOffset.Now, mockDescriptor.Object, new[] { mockEncryptorFactory.Object });
330var keyRing = new CacheableKeyRing(CancellationToken.None, DateTimeOffset.MaxValue, key, new[] { key });
333Key key2 = new Key(notFoundKeyId, DateTimeOffset.Now, DateTimeOffset.Now, DateTimeOffset.Now, mockDescriptor.Object, new[] { mockEncryptorFactory.Object });
334var keyRing2 = new CacheableKeyRing(CancellationToken.None, DateTimeOffset.MaxValue, key, new[] { key2 });
355public CacheableKeyRing GetCacheableKeyRing(DateTimeOffset now) => _keyRing;
370public CacheableKeyRing GetCacheableKeyRing(DateTimeOffset now)
395Key key = new Key(keyId, DateTimeOffset.Now, DateTimeOffset.Now, DateTimeOffset.Now, mockDescriptor.Object, new[] { mockEncryptorFactory.Object });
435Key defaultKey = new Key(defaultKeyId, DateTimeOffset.Now, DateTimeOffset.Now, DateTimeOffset.Now, mockDescriptor.Object, new[] { mockEncryptorFactory.Object });
482Key defaultKey = new Key(defaultKeyId, DateTimeOffset.Now, DateTimeOffset.Now, DateTimeOffset.Now, mockDescriptor.Object, new[] { mockEncryptorFactory.Object });
531Key defaultKey = new Key(defaultKeyId, DateTimeOffset.Now, DateTimeOffset.Now, DateTimeOffset.Now, new Mock<IAuthenticatedEncryptorDescriptor>().Object, new[] { mockEncryptorFactory.Object });
532Key embeddedKey = new Key(embeddedKeyId, DateTimeOffset.Now, DateTimeOffset.Now, DateTimeOffset.Now, mockDescriptor.Object, new[] { mockEncryptorFactory.Object });
563Key key = new Key(Guid.NewGuid(), DateTimeOffset.Now, DateTimeOffset.Now, DateTimeOffset.Now, new AuthenticatedEncryptorConfiguration().CreateNewDescriptor(), new[] { encryptorFactory });
KeyManagement\KeyRingProviderTests.cs (51)
36Tuple.Create((DateTimeOffset)now, (IEnumerable<IKey>)allKeys, new DefaultKeyResolution()
74Tuple.Create((DateTimeOffset)now, (IEnumerable<IKey>)allKeys, new DefaultKeyResolution()
118Tuple.Create((DateTimeOffset)now, (DateTimeOffset)now + TimeSpan.FromDays(90), CreateKey())
122Tuple.Create((DateTimeOffset)now, (IEnumerable<IKey>)allKeys1, new DefaultKeyResolution()
127Tuple.Create((DateTimeOffset)now, (IEnumerable<IKey>)allKeys2, new DefaultKeyResolution()
154var now = (DateTimeOffset)StringToDateTime("2015-03-01 00:00:00Z");
207Tuple.Create((DateTimeOffset)now, (DateTimeOffset)now + TimeSpan.FromDays(90), newlyCreatedKey)
211Tuple.Create((DateTimeOffset)now, (IEnumerable<IKey>)allKeys, new DefaultKeyResolution()
216Tuple.Create((DateTimeOffset)now, (IEnumerable<IKey>)allKeys, new DefaultKeyResolution()
251Tuple.Create((DateTimeOffset)now, (DateTimeOffset)now + TimeSpan.FromDays(90), CreateKey())
255Tuple.Create((DateTimeOffset)now, (IEnumerable<IKey>)allKeys, new DefaultKeyResolution()
291Tuple.Create(key1.ExpirationDate, (DateTimeOffset)now + TimeSpan.FromDays(90), CreateKey())
295Tuple.Create((DateTimeOffset)now, (IEnumerable<IKey>)allKeys1, new DefaultKeyResolution()
300Tuple.Create((DateTimeOffset)now, (IEnumerable<IKey>)allKeys2, new DefaultKeyResolution()
339Tuple.Create((DateTimeOffset)now, (IEnumerable<IKey>)allKeys, new DefaultKeyResolution()
377Tuple.Create((DateTimeOffset)now, (IEnumerable<IKey>)allKeys, new DefaultKeyResolution()
429DateTimeOffset now = StringToDateTime("2016-02-01 00:00:00Z");
432DateTimeOffset activation1 = now - TimeSpan.FromHours(1);
433DateTimeOffset activation2 = now + TimeSpan.FromHours(1);
435DateTimeOffset expiration1 = now + TimeSpan.FromHours(hoursToExpiration1);
436DateTimeOffset expiration2 = now + TimeSpan.FromHours(hoursToExpiration2);
458var resolveDefaultKeyPolicyReturnValues = new List<Tuple<DateTimeOffset, IEnumerable<IKey>, DefaultKeyResolution>>()
522DateTimeOffset now = StringToDateTime("2016-02-01 00:00:00Z");
525DateTimeOffset activation = now - TimeSpan.FromDays(30);
526DateTimeOffset expiration = now + TimeSpan.FromDays(30);
595mockCacheableKeyRingProvider.Verify(o => o.GetCacheableKeyRing(It.IsAny<DateTimeOffset>()), Times.Once);
636mockCacheableKeyRingProvider.Verify(o => o.GetCacheableKeyRing(It.IsAny<DateTimeOffset>()), Times.Exactly(2));
669mockCacheableKeyRingProvider.Verify(o => o.GetCacheableKeyRing(It.IsAny<DateTimeOffset>()), Times.Exactly(2));
720mockCacheableKeyRingProvider.Verify(o => o.GetCacheableKeyRing(It.IsAny<DateTimeOffset>()), Times.Once);
756IEnumerable<Tuple<DateTimeOffset, DateTimeOffset, IKey>> createNewKeyCallbacks,
757IEnumerable<Tuple<DateTimeOffset, IEnumerable<IKey>, DefaultKeyResolution>> resolveDefaultKeyPolicyReturnValues,
782mockKeyManager.Setup(o => o.CreateNewKey(It.IsAny<DateTimeOffset>(), It.IsAny<DateTimeOffset>()))
783.Returns<DateTimeOffset, DateTimeOffset>((activationDate, expirationDate) =>
795mockDefaultKeyResolver.Setup(o => o.ResolveDefaultKeyPolicy(It.IsAny<DateTimeOffset>(), It.IsAny<IEnumerable<IKey>>()))
796.Returns<DateTimeOffset, IEnumerable<IKey>>((now, allKeys) =>
909private static void AssertWithinJitterRange(DateTimeOffset actual, DateTimeOffset now)
917return DateTimeOffset.ParseExact(input, "u", CultureInfo.InvariantCulture).UtcDateTime;
922var now = DateTimeOffset.Now;
931DateTimeOffset.ParseExact(activationDate, "u", CultureInfo.InvariantCulture),
932DateTimeOffset.ParseExact(expirationDate, "u", CultureInfo.InvariantCulture),
936private static IKey CreateKey(DateTimeOffset activationDate, DateTimeOffset expirationDate, bool isRevoked = false)
KeyManagement\XmlKeyManagerTests.cs (32)
78var creationDate = new DateTimeOffset(2014, 01, 01, 0, 0, 0, TimeSpan.Zero);
79var activationDate = new DateTimeOffset(2014, 02, 01, 0, 0, 0, TimeSpan.Zero);
80var expirationDate = new DateTimeOffset(2014, 03, 01, 0, 0, 0, TimeSpan.Zero);
165var creationDate = new DateTimeOffset(2014, 01, 01, 0, 0, 0, TimeSpan.Zero);
166var activationDate = new DateTimeOffset(2014, 02, 01, 0, 0, 0, TimeSpan.Zero);
167var expirationDate = new DateTimeOffset(2014, 03, 01, 0, 0, 0, TimeSpan.Zero);
293DateTimeOffset minCreationDate = DateTimeOffset.UtcNow;
294DateTimeOffset? actualCreationDate = null;
295DateTimeOffset activationDate = minCreationDate + TimeSpan.FromDays(7);
296DateTimeOffset expirationDate = activationDate.AddMonths(1);
299.Setup(o => o.CreateNewKey(It.IsAny<Guid>(), It.IsAny<DateTimeOffset>(), activationDate, expirationDate))
300.Callback<Guid, DateTimeOffset, DateTimeOffset, DateTimeOffset>((innerKeyId, innerCreationDate, innerActivationDate, innerExpirationDate) =>
317Assert.InRange(actualCreationDate.Value, minCreationDate, DateTimeOffset.UtcNow);
635var revocationDate = XmlConvert.ToDateTimeOffset("2015-03-01T19:13:19.7573854-08:00");
685var revocationDate = new DateTimeOffset(2014, 01, 01, 0, 0, 0, TimeSpan.Zero);
722DateTimeOffset minRevocationDate = DateTimeOffset.UtcNow;
723DateTimeOffset? actualRevocationDate = null;
726.Setup(o => o.RevokeSingleKey(keyToRevoke, It.IsAny<DateTimeOffset>(), "Here's some reason text."))
727.Callback<Guid, DateTimeOffset, string>((innerKeyId, innerRevocationDate, innerReason) =>
744Assert.InRange(actualRevocationDate.Value, minRevocationDate, DateTimeOffset.UtcNow);
807var creationDate = DateTimeOffset.UtcNow;
808var activationDate = creationDate.AddDays(2);
809var expirationDate = creationDate.AddDays(90);
946var activationTime = DateTimeOffset.UtcNow.AddHours(1);
949keyManager.RevokeAllKeys(DateTimeOffset.UtcNow, "Revoking all keys"); // This should revoke key1
951keyManager.RevokeAllKeys(DateTimeOffset.UtcNow, "Revoking all keys"); // This should revoke key1 and key2
Microsoft.AspNetCore.DeveloperCertificates.XPlat (11)
Microsoft.AspNetCore.DeveloperCertificates.XPlat.Tests (32)
Microsoft.AspNetCore.Diagnostics.Tests (1)
Microsoft.AspNetCore.Grpc.JsonTranscoding.Tests (2)
Microsoft.AspNetCore.HeaderParsing (5)
Microsoft.AspNetCore.HeaderParsing.Tests (35)
Microsoft.AspNetCore.Hosting (4)
Microsoft.AspNetCore.Hosting.Tests (1)
Microsoft.AspNetCore.Http (4)
Microsoft.AspNetCore.Http.Abstractions (4)
Microsoft.AspNetCore.Http.Abstractions.Tests (2)
Microsoft.AspNetCore.Http.Connections (5)
Microsoft.AspNetCore.Http.Connections.Tests (8)
Microsoft.AspNetCore.Http.Extensions (26)
Microsoft.AspNetCore.Http.Extensions.Tests (10)
Microsoft.AspNetCore.Http.Features (1)
Microsoft.AspNetCore.Http.Results (74)
Results.cs (20)
285/// This API is an alias for <see cref="Bytes(byte[], string, string?, bool, DateTimeOffset?, EntityTagHeaderValue?)"/>.</para>
291/// <param name="lastModified">The <see cref="DateTimeOffset"/> of when the file was last modified.</param>
299DateTimeOffset? lastModified = null,
310/// This API is an alias for <see cref="File(byte[], string, string?, bool, DateTimeOffset?, EntityTagHeaderValue?)"/>.</para>
316/// <param name="lastModified">The <see cref="DateTimeOffset"/> of when the file was last modified.</param>
324DateTimeOffset? lastModified = null,
339/// <param name="lastModified">The <see cref="DateTimeOffset"/> of when the file was last modified.</param>
347DateTimeOffset? lastModified = null,
358/// This API is an alias for <see cref="Stream(Stream, string, string?, DateTimeOffset?, EntityTagHeaderValue?, bool)"/>.
364/// <param name="lastModified">The <see cref="DateTimeOffset"/> of when the file was last modified.
377DateTimeOffset? lastModified = null,
389/// This API is an alias for <see cref="File(Stream, string, string?, DateTimeOffset?, EntityTagHeaderValue?, bool)"/>.
395/// <param name="lastModified">The <see cref="DateTimeOffset"/> of when the file was last modified.
408DateTimeOffset? lastModified = null,
423/// <param name="lastModified">The <see cref="DateTimeOffset"/> of when the file was last modified.
436DateTimeOffset? lastModified = null,
447/// <param name="lastModified">The <see cref="DateTimeOffset"/> of when the file was last modified.
456DateTimeOffset? lastModified = null,
470/// <param name="lastModified">The <see cref="DateTimeOffset"/> of when the file was last modified.</param>
478DateTimeOffset? lastModified = null,
TypedResults.cs (22)
249/// This API is an alias for <see cref="Bytes(byte[], string, string?, bool, DateTimeOffset?, EntityTagHeaderValue?)"/>.</para>
255/// <param name="lastModified">The <see cref="DateTimeOffset"/> of when the file was last modified.</param>
263DateTimeOffset? lastModified = null,
284/// This API is an alias for <see cref="File(byte[], string, string?, bool, DateTimeOffset?, EntityTagHeaderValue?)"/>.</para>
290/// <param name="lastModified">The <see cref="DateTimeOffset"/> of when the file was last modified.</param>
298DateTimeOffset? lastModified = null,
323/// <param name="lastModified">The <see cref="DateTimeOffset"/> of when the file was last modified.</param>
331DateTimeOffset? lastModified = null,
348/// This API is an alias for <see cref="Stream(Stream, string, string?, DateTimeOffset?, EntityTagHeaderValue?, bool)"/>.
357/// <param name="lastModified">The <see cref="DateTimeOffset"/> of when the file was last modified.
367DateTimeOffset? lastModified = null,
389/// This API is an alias for <see cref="File(Stream, string, string?, DateTimeOffset?, EntityTagHeaderValue?, bool)"/>.
398/// <param name="lastModified">The <see cref="DateTimeOffset"/> of when the file was last modified.
408DateTimeOffset? lastModified = null,
436/// <param name="lastModified">The <see cref="DateTimeOffset"/> of when the file was last modified.
446DateTimeOffset? lastModified = null,
467/// <param name="lastModified">The <see cref="DateTimeOffset"/> of when the file was last modified.
476DateTimeOffset? lastModified = null,
499/// <param name="lastModified">The <see cref="DateTimeOffset"/> of when the file was last modified.</param>
507DateTimeOffset? lastModified = null,
532/// <param name="lastModified">The <see cref="DateTimeOffset"/> of when the file was last modified.</param>
540DateTimeOffset? lastModified = null,
Microsoft.AspNetCore.Http.Results.Tests (76)
ResultsTests.cs (7)
262public void BytesOrFile_ResultHasCorrectValues(int bytesOrFile, string contentType, string fileDownloadName, bool enableRangeProcessing, DateTimeOffset lastModified, EntityTagHeaderValue entityTag)
286new object[] { 0, default(string), default(string), default(bool), default(DateTimeOffset?), default(EntityTagHeaderValue) },
288new object[] { 1, default(string), default(string), default(bool), default(DateTimeOffset?), default(EntityTagHeaderValue) }
293public void Stream_ResultHasCorrectValues(int overload, string contentType, string fileDownloadName, bool enableRangeProcessing, DateTimeOffset lastModified, EntityTagHeaderValue entityTag)
334new object[] { 0, default(string), default(string), default(bool), default(DateTimeOffset?), default(EntityTagHeaderValue) },
336new object[] { 1, default(string), default(string), default(bool), default(DateTimeOffset?), default(EntityTagHeaderValue) },
338new object[] { 2, default(string), default(string), default(bool), default(DateTimeOffset?), default(EntityTagHeaderValue) }
TypedResultsTests.cs (11)
240public void BytesOrFile_ResultHasCorrectValues(int bytesOrFile, string contentType, string fileDownloadName, bool enableRangeProcessing, DateTimeOffset lastModified, EntityTagHeaderValue entityTag)
264new object[] { 0, default(string), default(string), default(bool), default(DateTimeOffset?), default(EntityTagHeaderValue) },
266new object[] { 1, default(string), default(string), default(bool), default(DateTimeOffset?), default(EntityTagHeaderValue) }
271public void PhysicalFile_ResultHasCorrectValues(string contentType, string fileDownloadName, bool enableRangeProcessing, DateTimeOffset lastModified, EntityTagHeaderValue entityTag)
290public void VirtualFile_ResultHasCorrectValues(string contentType, string fileDownloadName, bool enableRangeProcessing, DateTimeOffset lastModified, EntityTagHeaderValue entityTag)
310new object[] { default(string), default(string), default(bool), default(DateTimeOffset?), default(EntityTagHeaderValue) },
312new object[] { default(string), default(string), default(bool), default(DateTimeOffset?), default(EntityTagHeaderValue) }
377public void Stream_ResultHasCorrectValues(int overload, string contentType, string fileDownloadName, bool enableRangeProcessing, DateTimeOffset lastModified, EntityTagHeaderValue entityTag)
418new object[] { 0, default(string), default(string), default(bool), default(DateTimeOffset?), default(EntityTagHeaderValue) },
420new object[] { 1, default(string), default(string), default(bool), default(DateTimeOffset?), default(EntityTagHeaderValue) },
422new object[] { 2, default(string), default(string), default(bool), default(DateTimeOffset?), default(EntityTagHeaderValue) }
Microsoft.AspNetCore.Http.Tests (1)
Microsoft.AspNetCore.HttpOverrides.Tests (4)
Microsoft.AspNetCore.Identity (8)
Microsoft.AspNetCore.Identity.EntityFrameworkCore.Test (10)
Microsoft.AspNetCore.Identity.FunctionalTests (8)
Microsoft.AspNetCore.Identity.InMemory.Test (8)
Microsoft.AspNetCore.Identity.Specification.Tests (15)
Microsoft.AspNetCore.Identity.Test (15)
Microsoft.AspNetCore.InternalTesting (21)
AssemblyTestLog.cs (13)
68var logStart = DateTimeOffset.UtcNow;
93public ILoggerFactory CreateLoggerFactory(ITestOutputHelper output, string className, [CallerMemberName] string testName = null, DateTimeOffset? logStart = null)
97public ILoggerFactory CreateLoggerFactory(ITestOutputHelper output, string className, LogLevel minLogLevel, [CallerMemberName] string testName = null, DateTimeOffset? logStart = null)
101public IServiceProvider CreateLoggerServices(ITestOutputHelper output, string className, LogLevel minLogLevel, out string normalizedTestName, [CallerMemberName] string testName = null, DateTimeOffset? logStart = null)
105public IServiceProvider CreateLoggerServices(ITestOutputHelper output, string className, LogLevel minLogLevel, out string normalizedTestName, out string logOutputDirectory, [CallerMemberName] string testName = null, DateTimeOffset? logStart = null)
186var logStart = DateTimeOffset.UtcNow;
272private static SerilogLoggerProvider ConfigureFileLogging(string fileName, DateTimeOffset? logStart)
325private readonly DateTimeOffset? _logStart;
327public AssemblyLogTimestampOffsetEnricher(DateTimeOffset? logStart)
337? $"{(DateTimeOffset.UtcNow - _logStart.Value).TotalSeconds.ToString("N3", CultureInfo.InvariantCulture)}s"
338: DateTimeOffset.UtcNow.ToString("s", CultureInfo.InvariantCulture)));
Microsoft.AspNetCore.Mvc.Abstractions (5)
Microsoft.AspNetCore.Mvc.ApiExplorer (1)
Microsoft.AspNetCore.Mvc.ApiExplorer.Test (4)
Microsoft.AspNetCore.Mvc.Core (57)
ControllerBase.cs (32)
1132/// <param name="lastModified">The <see cref="DateTimeOffset"/> of when the file was last modified.</param>
1136public virtual FileContentResult File(byte[] fileContents, string contentType, DateTimeOffset? lastModified, EntityTagHeaderValue entityTag)
1153/// <param name="lastModified">The <see cref="DateTimeOffset"/> of when the file was last modified.</param>
1158public virtual FileContentResult File(byte[] fileContents, string contentType, DateTimeOffset? lastModified, EntityTagHeaderValue entityTag, bool enableRangeProcessing)
1177/// <param name="lastModified">The <see cref="DateTimeOffset"/> of when the file was last modified.</param>
1181public virtual FileContentResult File(byte[] fileContents, string contentType, string? fileDownloadName, DateTimeOffset? lastModified, EntityTagHeaderValue entityTag)
1200/// <param name="lastModified">The <see cref="DateTimeOffset"/> of when the file was last modified.</param>
1205public virtual FileContentResult File(byte[] fileContents, string contentType, string? fileDownloadName, DateTimeOffset? lastModified, EntityTagHeaderValue entityTag, bool enableRangeProcessing)
1298/// <param name="lastModified">The <see cref="DateTimeOffset"/> of when the file was last modified.</param>
1305public virtual FileStreamResult File(Stream fileStream, string contentType, DateTimeOffset? lastModified, EntityTagHeaderValue entityTag)
1322/// <param name="lastModified">The <see cref="DateTimeOffset"/> of when the file was last modified.</param>
1330public virtual FileStreamResult File(Stream fileStream, string contentType, DateTimeOffset? lastModified, EntityTagHeaderValue entityTag, bool enableRangeProcessing)
1349/// <param name="lastModified">The <see cref="DateTimeOffset"/> of when the file was last modified.</param>
1356public virtual FileStreamResult File(Stream fileStream, string contentType, string? fileDownloadName, DateTimeOffset? lastModified, EntityTagHeaderValue entityTag)
1375/// <param name="lastModified">The <see cref="DateTimeOffset"/> of when the file was last modified.</param>
1383public virtual FileStreamResult File(Stream fileStream, string contentType, string? fileDownloadName, DateTimeOffset? lastModified, EntityTagHeaderValue entityTag, bool enableRangeProcessing)
1464/// <param name="lastModified">The <see cref="DateTimeOffset"/> of when the file was last modified.</param>
1468public virtual VirtualFileResult File(string virtualPath, string contentType, DateTimeOffset? lastModified, EntityTagHeaderValue entityTag)
1485/// <param name="lastModified">The <see cref="DateTimeOffset"/> of when the file was last modified.</param>
1490public virtual VirtualFileResult File(string virtualPath, string contentType, DateTimeOffset? lastModified, EntityTagHeaderValue entityTag, bool enableRangeProcessing)
1509/// <param name="lastModified">The <see cref="DateTimeOffset"/> of when the file was last modified.</param>
1513public virtual VirtualFileResult File(string virtualPath, string contentType, string? fileDownloadName, DateTimeOffset? lastModified, EntityTagHeaderValue entityTag)
1532/// <param name="lastModified">The <see cref="DateTimeOffset"/> of when the file was last modified.</param>
1537public virtual VirtualFileResult File(string virtualPath, string contentType, string? fileDownloadName, DateTimeOffset? lastModified, EntityTagHeaderValue entityTag, bool enableRangeProcessing)
1625/// <param name="lastModified">The <see cref="DateTimeOffset"/> of when the file was last modified.</param>
1629public virtual PhysicalFileResult PhysicalFile(string physicalPath, string contentType, DateTimeOffset? lastModified, EntityTagHeaderValue entityTag)
1646/// <param name="lastModified">The <see cref="DateTimeOffset"/> of when the file was last modified.</param>
1651public virtual PhysicalFileResult PhysicalFile(string physicalPath, string contentType, DateTimeOffset? lastModified, EntityTagHeaderValue entityTag, bool enableRangeProcessing)
1670/// <param name="lastModified">The <see cref="DateTimeOffset"/> of when the file was last modified.</param>
1674public virtual PhysicalFileResult PhysicalFile(string physicalPath, string contentType, string? fileDownloadName, DateTimeOffset? lastModified, EntityTagHeaderValue entityTag)
1693/// <param name="lastModified">The <see cref="DateTimeOffset"/> of when the file was last modified.</param>
1698public virtual PhysicalFileResult PhysicalFile(string physicalPath, string contentType, string? fileDownloadName, DateTimeOffset? lastModified, EntityTagHeaderValue entityTag, bool enableRangeProcessing)
Microsoft.AspNetCore.Mvc.Core.Test (94)
Microsoft.AspNetCore.Mvc.FunctionalTests (5)
Microsoft.AspNetCore.Mvc.NewtonsoftJson (1)
Microsoft.AspNetCore.Mvc.TagHelpers (7)
Microsoft.AspNetCore.Mvc.TagHelpers.Test (16)
CacheTagHelperTest.cs (6)
194var expiresOn = DateTimeOffset.UtcNow.AddMinutes(4);
326var currentTime = new DateTimeOffset(2010, 1, 1, 0, 0, 0, TimeSpan.Zero);
379var currentTime = new DateTimeOffset(2010, 1, 1, 0, 0, 0, TimeSpan.Zero);
432var currentTime = new DateTimeOffset(2010, 1, 1, 0, 0, 0, TimeSpan.Zero);
972public DateTimeOffset? AbsoluteExpiration { get; set; }
DistributedCacheTagHelperTest.cs (5)
248var expiresOn = DateTimeOffset.UtcNow.AddMinutes(4);
349var currentTime = new DateTimeOffset(2010, 1, 1, 0, 0, 0, TimeSpan.Zero);
411var currentTime = new DateTimeOffset(2010, 1, 1, 0, 0, 0, TimeSpan.Zero);
473var currentTime = new DateTimeOffset(2010, 1, 1, 0, 0, 0, TimeSpan.Zero);
Microsoft.AspNetCore.Mvc.ViewFeatures (4)
Microsoft.AspNetCore.Mvc.ViewFeatures.Test (8)
Microsoft.AspNetCore.Mvc.Views.TestCommon (4)
Microsoft.AspNetCore.OpenApi (8)
Microsoft.AspNetCore.OpenApi.Tests (4)
Microsoft.AspNetCore.OutputCaching (9)
Microsoft.AspNetCore.OutputCaching.Microbenchmarks (3)
Microsoft.AspNetCore.OutputCaching.StackExchangeRedis (13)
Microsoft.AspNetCore.OutputCaching.Tests (56)
OutputCacheMiddlewareTests.cs (35)
77using (var entry = new OutputCacheEntry(DateTimeOffset.UtcNow, StatusCodes.Status200OK))
107using (var entry = new OutputCacheEntry(DateTimeOffset.UtcNow, StatusCodes.Status200OK)
136using (var entry = new OutputCacheEntry(DateTimeOffset.UtcNow, StatusCodes.Status200OK))
162using var entry = new OutputCacheEntry(DateTimeOffset.UtcNow, StatusCodes.Status200OK);
172var utcNow = DateTimeOffset.UtcNow;
176using var entry = new OutputCacheEntry(DateTimeOffset.UtcNow, StatusCodes.Status200OK);
181static void SetDateHeader(OutputCacheEntry entry, DateTimeOffset value)
210var utcNow = DateTimeOffset.UtcNow;
214using var entry = new OutputCacheEntry(DateTimeOffset.UtcNow, StatusCodes.Status200OK);
219static void SetDateHeaders(OutputCacheEntry entry, DateTimeOffset date, DateTimeOffset lastModified)
252var utcNow = DateTimeOffset.UtcNow;
256using var entry = new OutputCacheEntry(DateTimeOffset.UtcNow, StatusCodes.Status200OK);
273var utcNow = DateTimeOffset.UtcNow;
277using var entry = new OutputCacheEntry(DateTimeOffset.UtcNow, StatusCodes.Status200OK);
295using var entry = new OutputCacheEntry(DateTimeOffset.UtcNow, StatusCodes.Status200OK);
324using var entry = new OutputCacheEntry(DateTimeOffset.UtcNow, StatusCodes.Status200OK)
341using var entry = new OutputCacheEntry(DateTimeOffset.UtcNow, StatusCodes.Status200OK);
356using var entry = new OutputCacheEntry(DateTimeOffset.UtcNow, StatusCodes.Status200OK);
392var initialTime = timeProvider.GetUtcNow();
536var utcNow = DateTimeOffset.UtcNow;
556var utcNow = DateTimeOffset.UtcNow;
557var responseTime = utcNow + TimeSpan.FromSeconds(10);
615using var entry = new OutputCacheEntry(DateTimeOffset.UtcNow, StatusCodes.Status200OK);
644using var entry = new OutputCacheEntry(DateTimeOffset.UtcNow, StatusCodes.Status200OK);
677using var entry = new OutputCacheEntry(DateTimeOffset.UtcNow, StatusCodes.Status200OK);
702using var entry = new OutputCacheEntry(DateTimeOffset.UtcNow, StatusCodes.Status200OK);
774using var entry = new OutputCacheEntry(DateTimeOffset.UtcNow, StatusCodes.Status200OK);
978using var entry = new OutputCacheEntry(DateTimeOffset.UtcNow, StatusCodes.Status200OK);
Microsoft.AspNetCore.ResponseCaching (16)
Microsoft.AspNetCore.ResponseCaching.Tests (49)
Microsoft.AspNetCore.Rewrite (12)
Microsoft.AspNetCore.Rewrite.Tests (2)
Microsoft.AspNetCore.Routing (3)
Microsoft.AspNetCore.Server.HttpSys (4)
Microsoft.AspNetCore.Server.IIS (2)
Microsoft.AspNetCore.Server.Kestrel.Core (15)
Microsoft.AspNetCore.Server.Kestrel.Core.Tests (39)
Microsoft.AspNetCore.Server.Kestrel.Transport.NamedPipes (2)
Microsoft.AspNetCore.Server.Kestrel.Transport.Quic (2)
Microsoft.AspNetCore.Session.Tests (1)
Microsoft.AspNetCore.SignalR.Common.Tests (6)
Internal\Protocol\JsonHubProtocolTestsBase.cs (2)
38new JsonProtocolTestData("InvocationMessage_DateTimeOffsetArgument", new InvocationMessage("Method", new object[] { DateTimeOffset.Parse("2016-05-10T13:51:20+12:34", CultureInfo.InvariantCulture) }), true, true, "{\"type\":1,\"target\":\"Method\",\"arguments\":[\"2016-05-10T13:51:20+12:34\"]}"),
103new JsonProtocolTestData("InvocationMessage_DateTimeOffsetArgumentFirst", new InvocationMessage("Method", new object[] { DateTimeOffset.Parse("2016-05-10T13:51:20+12:34", CultureInfo.InvariantCulture) }), false, true, "{ \"arguments\": [\"2016-05-10T13:51:20+12:34\"], \"type\":1, \"target\": \"Method\" }"),
Microsoft.AspNetCore.SignalR.Protocols.NewtonsoftJson (2)
Microsoft.AspNetCore.StaticAssets (8)
Microsoft.AspNetCore.StaticAssets.Tests (14)
Microsoft.AspNetCore.StaticFiles (4)
Microsoft.AspNetCore.StaticFiles.FunctionalTests (1)
Microsoft.AspNetCore.StaticFiles.Tests (13)
Microsoft.AspNetCore.Testing (2)
Microsoft.Build (7)
Logging\BinaryLogger\ProjectImportsCollector.cs (6)
103DateTimeOffset? entryCreationStamp = null,
113DateTimeOffset? entryCreationStamp = null,
188private void AddFileFromMemoryCore(string filePath, string data, bool makePathAbsolute, DateTimeOffset? entryCreationStamp)
200private void AddFileFromMemoryCore(string filePath, Stream data, bool makePathAbsolute, DateTimeOffset? entryCreationStamp)
211private void AddFileData(string filePath, Stream data, DateTimeOffset? entryCreationStamp)
242private Stream OpenArchiveEntry(string filePath, DateTimeOffset? entryCreationStamp)
Microsoft.Build.Tasks.UnitTests (1)
Microsoft.CodeAnalysis.Features (2)
Microsoft.DotNet.ArcadeLogging (8)
Microsoft.DotNet.Build.Tasks.Feed (3)
Microsoft.DotNet.Build.Tasks.Feed.Tests (1)
Microsoft.DotNet.Build.Tasks.Installers (3)
src\RpmBuilder.cs (3)
181private static readonly DateTimeOffset UnixEpoch = new(1970, 1, 1, 0, 0, 0, TimeSpan.Zero);
211entries.Add(new(RpmHeaderTag.ChangelogTimestamp, RpmHeaderEntryType.Int32, _changelogLines.Select(_ => (int)(DateTimeOffset.UtcNow - UnixEpoch).TotalSeconds).ToArray()));
213entries.Add(new(RpmHeaderTag.BuildTime, RpmHeaderEntryType.Int32, new[] { (int)(DateTimeOffset.UtcNow - UnixEpoch).TotalSeconds }));
Microsoft.DotNet.Helix.Client (39)
Microsoft.DotNet.SignCheckLibrary (1)
Microsoft.DotNet.XUnitAssert.Tests (22)
EqualityAssertsTests.cs (16)
1812 var expected = new DateTimeOffset(2023, 2, 11, 15, 4, 0, TimeSpan.Zero);
1813 var actual = new DateTimeOffset(2023, 2, 11, 15, 4, 0, TimeSpan.Zero);
1826 var expected = new DateTimeOffset(2023, 2, 11, 15, 4, 0, TimeSpan.Zero);
1827 var actual = new DateTimeOffset(2023, 2, 11, 15, 5, 0, TimeSpan.Zero);
1846 var expected = new DateTimeOffset(2023, 2, 11, 15, 4, 0, TimeSpan.Zero);
1847 var actual = new DateTimeOffset(2023, 2, 11, 16, 4, 0, TimeSpan.FromHours(1));
1859 var expected = new DateTimeOffset(2023, 2, 11, 15, 4, 0, TimeSpan.Zero);
1860 var actual = new DateTimeOffset(2023, 2, 11, 15, 4, 0, TimeSpan.FromHours(1));
1879 var date1 = new DateTimeOffset(2023, 2, 11, 15, 4, 0, TimeSpan.Zero);
1880 var date2 = new DateTimeOffset(2023, 2, 11, 15, 5, 0, TimeSpan.Zero);
1894 var date1 = new DateTimeOffset(2023, 2, 11, 15, 4, 0, TimeSpan.Zero);
1895 var date2 = new DateTimeOffset(2023, 2, 11, 15, 6, 0, TimeSpan.Zero);
1928 var date1 = new DateTimeOffset(2023, 2, 11, 15, 4, 0, TimeSpan.Zero);
1929 var date2 = new DateTimeOffset(2023, 2, 11, 16, 5, 0, TimeSpan.FromHours(1));
1943 var date1 = new DateTimeOffset(2023, 2, 11, 15, 4, 0, TimeSpan.Zero);
1944 var date2 = new DateTimeOffset(2023, 2, 11, 15, 4, 0, TimeSpan.FromHours(1));
EquivalenceAssertsTests.cs (4)
1503 var expected = new DateTimeOffset(2022, 12, 1, 1, 3, 1, TimeSpan.Zero);
1504 var actual = new DateTimeOffset(2022, 12, 1, 1, 3, 1, TimeSpan.Zero);
1512 var expected = new DateTimeOffset(2022, 12, 1, 1, 3, 1, TimeSpan.Zero);
1513 var actual = new DateTimeOffset(2011, 9, 13, 18, 22, 0, TimeSpan.Zero);
Microsoft.Extensions.AI (1)
Microsoft.Extensions.AI.Abstractions (4)
Microsoft.Extensions.AI.Abstractions.Tests (9)
Microsoft.Extensions.AI.AzureAIInference (3)
Microsoft.Extensions.AI.AzureAIInference.Tests (8)
Microsoft.Extensions.AI.Evaluation.Reporting.Azure (1)
Microsoft.Extensions.AI.Integration.Tests (1)
Microsoft.Extensions.AI.Ollama (5)
Microsoft.Extensions.AI.Ollama.Tests (6)
Microsoft.Extensions.AI.OpenAI (3)
Microsoft.Extensions.AI.OpenAI.Tests (15)
Microsoft.Extensions.AI.Tests (5)
Microsoft.Extensions.Caching.Abstractions (13)
Microsoft.Extensions.Caching.Hybrid.Tests (4)
Microsoft.Extensions.Caching.Memory (2)
Microsoft.Extensions.Caching.SqlServer (12)
Microsoft.Extensions.Caching.SqlServer.Tests (21)
Microsoft.Extensions.Caching.StackExchangeRedis (31)
RedisCache.cs (31)
52private long _lastConnectTicks = DateTimeOffset.UtcNow.Ticks;
68private static DateTimeOffset ReadTimeTicks(ref long field)
71return ticks == 0 ? DateTimeOffset.MinValue : new DateTimeOffset(ticks, TimeSpan.Zero);
74private static void WriteTimeTicks(ref long field, DateTimeOffset value)
76var ticks = value == DateTimeOffset.MinValue ? 0L : value.UtcTicks;
169var creationTime = DateTimeOffset.UtcNow;
219var creationTime = DateTimeOffset.UtcNow;
249private static HashEntry[] GetHashFields(RedisValue value, DateTimeOffset? absoluteExpiration, TimeSpan? slidingExpiration)
359WriteTimeTicks(ref _lastConnectTicks, DateTimeOffset.UtcNow);
413MapMetadata(results, out DateTimeOffset? absExpr, out TimeSpan? sldExpr);
452MapMetadata(results, out DateTimeOffset? absExpr, out TimeSpan? sldExpr);
503private static void MapMetadata(RedisValue[] results, out DateTimeOffset? absoluteExpiration, out TimeSpan? slidingExpiration)
519private void Refresh(IDatabase cache, string key, DateTimeOffset? absExpr, TimeSpan sldExpr)
527var relExpr = absExpr.Value - DateTimeOffset.Now;
545private async Task RefreshAsync(IDatabase cache, string key, DateTimeOffset? absExpr, TimeSpan sldExpr, CancellationToken token)
555var relExpr = absExpr.Value - DateTimeOffset.Now;
576private static long? GetExpirationInSeconds(DateTimeOffset creationTime, DateTimeOffset? absoluteExpiration, DistributedCacheEntryOptions options)
595private static DateTimeOffset? GetAbsoluteExpiration(DateTimeOffset creationTime, DistributedCacheEntryOptions options)
637var utcNow = DateTimeOffset.UtcNow;
638var previousConnectTime = ReadTimeTicks(ref _lastConnectTicks);
647var firstErrorTime = ReadTimeTicks(ref _firstErrorTimeTicks);
648if (firstErrorTime == DateTimeOffset.MinValue)
671WriteTimeTicks(ref _firstErrorTimeTicks, DateTimeOffset.MinValue);
672WriteTimeTicks(ref _previousErrorTimeTicks, DateTimeOffset.MinValue);
731MapMetadata(metadata, out DateTimeOffset? absExpr, out TimeSpan? sldExpr);
778MapMetadata(metadata, out DateTimeOffset? absExpr, out TimeSpan? sldExpr);
Microsoft.Extensions.Caching.StackExchangeRedis.Tests (4)
Microsoft.Extensions.Configuration.KeyPerFile.Tests (1)
Microsoft.Extensions.Diagnostics.ResourceMonitoring (9)
Microsoft.Extensions.Diagnostics.ResourceMonitoring.Tests (12)
Microsoft.Extensions.Diagnostics.Testing (4)
Microsoft.Extensions.Diagnostics.Testing.Tests (21)
Microsoft.Extensions.FileProviders.Abstractions (4)
Microsoft.Extensions.FileProviders.Embedded (16)
Microsoft.Extensions.FileProviders.Embedded.Tests (7)
Microsoft.Extensions.FileProviders.Physical (2)
Microsoft.Extensions.Http.Diagnostics.Tests (1)
Microsoft.Extensions.Identity.Core (14)
Microsoft.Extensions.Identity.Stores (7)
Microsoft.Extensions.Logging.Abstractions (1)
Microsoft.Extensions.Logging.AzureAppServices (10)
BatchingLogger.cs (2)
31public void Log<TState>(DateTimeOffset timestamp, LogLevel logLevel, EventId _, TState state, Exception exception, Func<TState, Exception, string> formatter)
72Log(DateTimeOffset.Now, logLevel, eventId, state, exception, formatter);
Microsoft.Extensions.Logging.Console (15)
Microsoft.Extensions.ServiceDiscovery.Dns.Tests (8)
Microsoft.Extensions.Telemetry (3)
Microsoft.Extensions.TimeProvider.Testing (7)
Microsoft.Extensions.TimeProvider.Testing.Tests (22)
FakeTimeProviderTests.cs (14)
19var now = timeProvider.GetUtcNow();
36var now2 = timeProvider.GetUtcNow();
46var nowOffset = new DateTimeOffset(2000, 1, 1, 0, 0, 0, 0, TimeSpan.Zero);
60var nowOffset = new DateTimeOffset(2000, 1, 1, 0, 0, 0, 0, TimeSpan.Zero);
108var now = timeProvider.GetUtcNow();
164var initialTimeUtcNow = timeProvider.GetUtcNow();
169var finalTimeUtcNow = timeProvider.GetUtcNow();
188var initialTimeUtcNow = timeProvider.GetUtcNow();
193var finalTimeUtcNow = timeProvider.GetUtcNow();
280var dto = new DateTimeOffset(new DateTime(2022, 1, 2, 3, 4, 5, 6), TimeSpan.Zero);
444var timeProvider = new FakeTimeProvider(DateTimeOffset.UtcNow)
449var first = timeProvider.GetUtcNow();
450var second = timeProvider.GetUtcNow();
451var third = timeProvider.GetUtcNow();
Microsoft.Extensions.Validation (1)
Microsoft.Extensions.Validation.Tests (1)
Microsoft.Gen.Logging.Generated.Tests (6)
Microsoft.Maui.Essentials (15)
Preferences\Preferences.shared.cs (9)
234 public static DateTimeOffset Get(string key, DateTimeOffset defaultValue) =>
238 public static void Set(string key, DateTimeOffset value) =>
250 public static DateTimeOffset Get(string key, DateTimeOffset defaultValue, string? sharedName) =>
251 Current.Get<DateTimeOffset>(key, defaultValue, sharedName);
254 public static void Set(string key, DateTimeOffset value, string? sharedName) =>
255 Current.Set<DateTimeOffset>(key, value, sharedName);
282 typeof(DateTimeOffset)
Microsoft.ML.Core (4)
Microsoft.ML.Core.Tests (2)
Microsoft.ML.Data (44)
Data\Conversion.cs (19)
19using DZ = DateTimeOffset;
238AddStd<TX, DZ>(Convert);
263AddStd<DZ, I8>(Convert);
264AddStd<DZ, R4>(Convert);
265AddStd<DZ, R8>(Convert);
266AddAux<DZ, SB>(Convert);
267AddStd<DZ, TX>(Convert);
293AddIsDef<DZ>(IsDefault);
315AddTryParse<DZ>(TryParse);
791private bool IsDefault(in DZ src) => src.Equals(default(DZ));
835public void Convert(in DZ src, ref I8 dst) => dst = (I8)src.UtcDateTime.Ticks;
893public void Convert(in DZ src, ref R4 dst) => dst = (R4)src.UtcDateTime.Ticks;
911public void Convert(in DZ src, ref R8 dst) => dst = (R8)src.UtcDateTime.Ticks;
936public void Convert(in DZ src, ref SB dst) { ClearDst(ref dst); dst.AppendFormat("{0:o}", src); }
954public void Convert(in DZ src, ref TX dst) => dst = string.Format("{0:o}", src).AsMemory();
1435public bool TryParse(in TX src, out DZ dst)
1443if (DateTimeOffset.TryParse(src.ToString(), CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal, out dst))
1717public void Convert(in TX span, ref DZ value) => TryParse(in span, out value);
Transforms\ConversionsExtensionsCatalog.cs (12)
228/// The input data types can be numeric, text, boolean, <see cref="System.DateTime"/> or <see cref="System.DateTimeOffset"/>.
263/// The input data types can be numeric, text, boolean, <see cref="System.DateTime"/> or <see cref="System.DateTimeOffset"/>.
301/// The input data types can be numeric, text, boolean, <see cref="System.DateTime"/> or <see cref="System.DateTimeOffset"/>.
318/// The output data types can be primitives or vectors of numeric, text, boolean, <see cref="System.DateTime"/>, <see cref="System.DateTimeOffset"/> or <see cref="DataViewRowId"/> types.</param>
322/// The input data types can be primitives or vectors of numeric, text, boolean, <see cref="System.DateTime"/>, <see cref="System.DateTimeOffset"/> or <see cref="DataViewRowId"/> types.
361/// The data types can be primitives or vectors of numeric, text, boolean, <see cref="System.DateTime"/>, <see cref="System.DateTimeOffset"/> or <see cref="DataViewRowId"/> types.
394/// The data types can be primitives or vectors of numeric, text, boolean, <see cref="System.DateTime"/>, <see cref="System.DateTimeOffset"/> or <see cref="DataViewRowId"/> types.
425/// The data types can be primitives or vectors of numeric, text, boolean, <see cref="System.DateTime"/>, <see cref="System.DateTimeOffset"/> or <see cref="DataViewRowId"/> types,
429/// The data types can be primitives or vectors of numeric, text, boolean, <see cref="System.DateTime"/>, <see cref="System.DateTimeOffset"/> or <see cref="DataViewRowId"/> types,
466/// <see cref="System.DateTimeOffset"/> or <see cref="DataViewRowId"/> types, as specified in the <typeparamref name="TInputType"/> and <typeparamref name="TOutputType"/>.</param>
494/// The data types can be primitives or vectors of numeric, text, boolean, <see cref="System.DateTime"/>, <see cref="System.DateTimeOffset"/>
500/// The data types can be primitives or vectors of numeric, text, boolean, <see cref="System.DateTime"/>, <see cref="System.DateTimeOffset"/>
Microsoft.ML.DataView (2)
Microsoft.ML.IntegrationTests (2)
Microsoft.ML.Parquet (4)
Microsoft.ML.TestFramework (4)
Microsoft.ML.Tests (1)
Microsoft.ML.Transforms (2)
Microsoft.Net.Http.Headers (24)
Microsoft.Net.Http.Headers.Tests (10)
mscorlib (1)
NativeIISSample (1)
netstandard (1)
OpenIdConnectSample (2)
RazorBuildWebSite (2)
RazorWebSite (1)
Sample (1)
Shared (4)
Shared.Tests (4)
SignalR.Client.FunctionalTestApp (2)
SocialSample (4)
Sockets.FunctionalTests (6)
Stress.ApiService (1)
System.Collections.Immutable (1)
System.ComponentModel.TypeConverter (17)
System\ComponentModel\DateTimeOffsetConverter.cs (16)
11/// Provides a type converter to convert <see cref='System.DateTimeOffset'/>
18/// object in the given source type to a <see cref='System.DateTimeOffset'/>
46return DateTimeOffset.MinValue;
61return DateTimeOffset.Parse(text, formatInfo);
65return DateTimeOffset.Parse(text, culture);
70throw new FormatException(SR.Format(SR.ConvertInvalidPrimitive, (string)value, nameof(DateTimeOffset)), e);
78/// Converts the given value object to a <see cref='System.DateTimeOffset'/>
85if (destinationType == typeof(string) && value is DateTimeOffset)
87DateTimeOffset dto = (DateTimeOffset)value;
88if (dto == DateTimeOffset.MinValue)
131if (destinationType == typeof(InstanceDescriptor) && value is DateTimeOffset)
133DateTimeOffset dto = (DateTimeOffset)value;
138typeof(DateTimeOffset).GetConstructor(new Type[] { typeof(long) }),
144typeof(DateTimeOffset).GetConstructor(new Type[] { typeof(int), typeof(int), typeof(int), typeof(int), typeof(int), typeof(int), typeof(int), typeof(TimeSpan) }),
System.Data.Common (41)
System.Diagnostics.DiagnosticSource (12)
System\Diagnostics\ActivityEvent.cs (6)
21public ActivityEvent(string name) : this(name, DateTimeOffset.UtcNow, tags: null)
31public ActivityEvent(string name, DateTimeOffset timestamp = default, ActivityTagsCollection? tags = null) : this(name, timestamp, tags, tags is null ? 0 : tags.Count) { }
33internal ActivityEvent(string name, DateTimeOffset timestamp, ref TagList tags) : this(name, timestamp, tags, tags.Count) { }
35private ActivityEvent(string name, DateTimeOffset timestamp, IEnumerable<KeyValuePair<string, object?>>? tags, int tagsCount)
38Timestamp = timestamp != default ? timestamp : DateTimeOffset.UtcNow;
51public DateTimeOffset Timestamp { get; }
System\Diagnostics\ActivitySource.cs (4)
174public Activity? StartActivity(string name, ActivityKind kind, ActivityContext parentContext, IEnumerable<KeyValuePair<string, object?>>? tags = null, IEnumerable<ActivityLink>? links = null, DateTimeOffset startTime = default)
187public Activity? StartActivity(string name, ActivityKind kind, string? parentId, IEnumerable<KeyValuePair<string, object?>>? tags = null, IEnumerable<ActivityLink>? links = null, DateTimeOffset startTime = default)
200public Activity? StartActivity(ActivityKind kind, ActivityContext parentContext = default, IEnumerable<KeyValuePair<string, object?>>? tags = null, IEnumerable<ActivityLink>? links = null, DateTimeOffset startTime = default, [CallerMemberName] string name = "")
204IEnumerable<ActivityLink>? links, DateTimeOffset startTime, bool startIt = true, ActivityIdFormat idFormat = ActivityIdFormat.Unknown)
System.Formats.Asn1 (24)
System.Formats.Cbor (8)
System.Formats.Tar (34)
System.IO.Compression (3)
System.IO.Compression.ZipFile (1)
System.IO.IsolatedStorage (3)
System.Linq.Expressions (2)
System.Net.Http (40)
System\Net\Http\Headers\WarningHeaderValue.cs (7)
16private readonly DateTimeOffset _date;
25public DateTimeOffset? Date => _dateHasValue ? _date : null;
27private WarningHeaderValue(int code, string agent, string text, DateTimeOffset? date)
52public WarningHeaderValue(int code, string agent, string text, DateTimeOffset date)
172if (!TryReadDate(input, ref current, out DateTimeOffset? date))
239private static bool TryReadDate(string input, ref int current, out DateTimeOffset? date)
266if (!HttpDateParser.TryParse(input.AsSpan(dateStartIndex, current - dateStartIndex), out DateTimeOffset temp))
System.Net.Mail (1)
System.Net.Requests (5)
System.Net.Security (19)
System.Private.CoreLib (200)
src\libraries\System.Private.CoreLib\src\System\Buffers\Text\Utf8Parser\Utf8Parser.Date.cs (4)
38if (!TryParseDateTimeOffsetR(source, NoFlipCase, out DateTimeOffset dateTimeOffset, out bytesConsumed))
49if (!TryParseDateTimeOffsetR(source, FlipCase, out DateTimeOffset dateTimeOffset, out bytesConsumed))
67if (!TryParseDateTimeOffsetO(source, out DateTimeOffset dateTimeOffset, out bytesConsumed, out DateTimeKind kind))
121public static bool TryParse(ReadOnlySpan<byte> source, out DateTimeOffset value, out int bytesConsumed, char standardFormat = default)
src\libraries\System.Private.CoreLib\src\System\Buffers\Text\Utf8Parser\Utf8Parser.Date.Helpers.cs (3)
14private static bool TryCreateDateTimeOffset(DateTime dateTime, bool offsetNegative, int offsetHours, int offsetMinutes, out DateTimeOffset value)
58private static bool TryCreateDateTimeOffset(int year, int month, int day, int hour, int minute, int second, int fraction, bool offsetNegative, int offsetHours, int offsetMinutes, out DateTimeOffset value)
78private static bool TryCreateDateTimeOffsetInterpretingDataAsLocalTime(int year, int month, int day, int hour, int minute, int second, int fraction, out DateTimeOffset value)
src\libraries\System.Private.CoreLib\src\System\DateTimeOffset.cs (92)
41IComparable<DateTimeOffset>,
42IEquatable<DateTimeOffset>,
45ISpanParsable<DateTimeOffset>,
61public static readonly DateTimeOffset MinValue;
62public static readonly DateTimeOffset MaxValue = new DateTimeOffset(0, DateTime.CreateUnchecked(DateTime.MaxTicks));
63public static readonly DateTimeOffset UnixEpoch = new DateTimeOffset(0, DateTime.CreateUnchecked(DateTime.UnixEpochTicks));
85private static DateTimeOffset CreateValidateOffset(DateTime dateTime, TimeSpan offset) => new DateTimeOffset(ValidateOffset(offset), ValidateDate(dateTime, offset));
129/// Initializes a new instance of the <see cref="DateTimeOffset"/> structure by <paramref name="date"/>, <paramref name="time"/> and <paramref name="offset"/>.
159DateTimeOffset value = new(year, month, day, hour, minute, 59, offset);
194DateTimeOffset value = new DateTimeOffset(year, month, day, hour, minute, 59, millisecond, calendar, offset);
200/// Initializes a new instance of the <see cref="DateTimeOffset"/> structure using the
218/// in the Gregorian calendar. To instantiate a <see cref="DateTimeOffset"/> value by using the year, month and day in another calendar, call
259/// Initializes a new instance of the <see cref="DateTimeOffset"/> structure using the
275/// in the Gregorian calendar. To instantiate a <see cref="DateTimeOffset"/> value by using the year, month and day in another calendar, call
332public static DateTimeOffset UtcNow => new DateTimeOffset(0, DateTime.SpecifyKind(DateTime.UtcNow, DateTimeKind.Unspecified));
342public DateTimeOffset ToOffset(TimeSpan offset) => CreateValidateOffset(_dateTime + offset, offset);
385/// Gets the microsecond component of the time represented by the current <see cref="DateTimeOffset"/> object.
395/// Gets the nanosecond component of the time represented by the current <see cref="DateTimeOffset"/> object.
447public DateTimeOffset Add(TimeSpan timeSpan) => Add(ClockDateTime.Add(timeSpan));
455public DateTimeOffset AddDays(double days) => Add(ClockDateTime.AddDays(days));
463public DateTimeOffset AddHours(double hours) => Add(ClockDateTime.AddHours(hours));
471public DateTimeOffset AddMilliseconds(double milliseconds) => Add(ClockDateTime.AddMilliseconds(milliseconds));
474/// Returns a new <see cref="DateTimeOffset"/> object that adds a specified number of microseconds to the value of this instance.
478/// An object whose value is the sum of the date and time represented by the current <see cref="DateTimeOffset"/> object and the number
486/// Because a <see cref="DateTimeOffset"/> object does not represent the date and time in a specific time zone,
491/// The resulting <see cref="DateTimeOffset"/> value is less than <see cref="MinValue"/>
495/// The resulting <see cref="DateTimeOffset"/> value is greater than <see cref="MaxValue"/>
497public DateTimeOffset AddMicroseconds(double microseconds) => Add(ClockDateTime.AddMicroseconds(microseconds));
505public DateTimeOffset AddMinutes(double minutes) => Add(ClockDateTime.AddMinutes(minutes));
507public DateTimeOffset AddMonths(int months) => Add(ClockDateTime.AddMonths(months));
515public DateTimeOffset AddSeconds(double seconds) => Add(ClockDateTime.AddSeconds(seconds));
521public DateTimeOffset AddTicks(long ticks) => Add(ClockDateTime.AddTicks(ticks));
531public DateTimeOffset AddYears(int years) => Add(ClockDateTime.AddYears(years));
533private DateTimeOffset Add(DateTime dateTime) => new DateTimeOffset(_offsetMinutes, ValidateDate(dateTime, Offset));
538public static int Compare(DateTimeOffset first, DateTimeOffset second) =>
549if (obj is not DateTimeOffset other)
557public int CompareTo(DateTimeOffset other) =>
566obj is DateTimeOffset && UtcTicks == ((DateTimeOffset)obj).UtcTicks;
568public bool Equals(DateTimeOffset other) => UtcTicks == other.UtcTicks;
571public bool EqualsExact(DateTimeOffset other) => UtcTicks == other.UtcTicks && _offsetMinutes == other._offsetMinutes;
577public static bool Equals(DateTimeOffset first, DateTimeOffset second) => first.UtcTicks == second.UtcTicks;
583public static DateTimeOffset FromFileTime(long fileTime) =>
586public static DateTimeOffset FromUnixTimeSeconds(long seconds)
597public static DateTimeOffset FromUnixTimeMilliseconds(long milliseconds)
650public static DateTimeOffset Parse(string input)
665public static DateTimeOffset Parse(string input, IFormatProvider? formatProvider)
668public static DateTimeOffset Parse(string input, IFormatProvider? formatProvider, DateTimeStyles styles)
680public static DateTimeOffset Parse(ReadOnlySpan<char> input, IFormatProvider? formatProvider = null, DateTimeStyles styles = DateTimeStyles.None)
691public static DateTimeOffset ParseExact(string input, [StringSyntax(StringSyntaxAttribute.DateTimeFormat)] string format, IFormatProvider? formatProvider)
698public static DateTimeOffset ParseExact(string input, [StringSyntax(StringSyntaxAttribute.DateTimeFormat)] string format, IFormatProvider? formatProvider, DateTimeStyles styles)
712public static DateTimeOffset ParseExact(ReadOnlySpan<char> input, [StringSyntax(StringSyntaxAttribute.DateTimeFormat)] ReadOnlySpan<char> format, IFormatProvider? formatProvider, DateTimeStyles styles = DateTimeStyles.None)
719public static DateTimeOffset ParseExact(string input, [StringSyntax(StringSyntaxAttribute.DateTimeFormat)] string[] formats, IFormatProvider? formatProvider, DateTimeStyles styles)
732public static DateTimeOffset ParseExact(ReadOnlySpan<char> input, [StringSyntax(StringSyntaxAttribute.DateTimeFormat)] string[] formats, IFormatProvider? formatProvider, DateTimeStyles styles = DateTimeStyles.None)
739public TimeSpan Subtract(DateTimeOffset value) => new TimeSpan(UtcTicks - value.UtcTicks);
741public DateTimeOffset Subtract(TimeSpan value) => Add(ClockDateTime.Subtract(value));
775public DateTimeOffset ToLocalTime() => ToLocalTime(UtcDateTime, false);
777private static DateTimeOffset ToLocalTime(DateTime utcDateTime, bool throwOnOverflow)
811public DateTimeOffset ToUniversalTime() => new DateTimeOffset(0, _dateTime);
813public static bool TryParse([NotNullWhen(true)] string? input, out DateTimeOffset result)
824public static bool TryParse(ReadOnlySpan<char> input, out DateTimeOffset result)
831public static bool TryParse([NotNullWhen(true)] string? input, IFormatProvider? formatProvider, DateTimeStyles styles, out DateTimeOffset result)
849public static bool TryParse(ReadOnlySpan<char> input, IFormatProvider? formatProvider, DateTimeStyles styles, out DateTimeOffset result)
858out DateTimeOffset result)
878ReadOnlySpan<char> input, [StringSyntax(StringSyntaxAttribute.DateTimeFormat)] ReadOnlySpan<char> format, IFormatProvider? formatProvider, DateTimeStyles styles, out DateTimeOffset result)
887out DateTimeOffset result)
907ReadOnlySpan<char> input, [NotNullWhen(true), StringSyntax(StringSyntaxAttribute.DateTimeFormat)] string?[]? formats, IFormatProvider? formatProvider, DateTimeStyles styles, out DateTimeOffset result)
976public static implicit operator DateTimeOffset(DateTime dateTime) =>
979public static DateTimeOffset operator +(DateTimeOffset dateTimeOffset, TimeSpan timeSpan) =>
982public static DateTimeOffset operator -(DateTimeOffset dateTimeOffset, TimeSpan timeSpan) =>
985public static TimeSpan operator -(DateTimeOffset left, DateTimeOffset right) =>
988public static bool operator ==(DateTimeOffset left, DateTimeOffset right) =>
991public static bool operator !=(DateTimeOffset left, DateTimeOffset right) =>
995public static bool operator <(DateTimeOffset left, DateTimeOffset right) =>
999public static bool operator <=(DateTimeOffset left, DateTimeOffset right) =>
1003public static bool operator >(DateTimeOffset left, DateTimeOffset right) =>
1007public static bool operator >=(DateTimeOffset left, DateTimeOffset right) =>
1011/// Deconstructs <see cref="DateTimeOffset"/> into <see cref="DateOnly"/>, <see cref="TimeOnly"/> and <see cref="TimeSpan"/>.
1034public static bool TryParse([NotNullWhen(true)] string? s, IFormatProvider? provider, out DateTimeOffset result) => TryParse(s, provider, DateTimeStyles.None, out result);
1041public static DateTimeOffset Parse(ReadOnlySpan<char> s, IFormatProvider? provider) => Parse(s, provider, DateTimeStyles.None);
1044public static bool TryParse(ReadOnlySpan<char> s, IFormatProvider? provider, out DateTimeOffset result) => TryParse(s, provider, DateTimeStyles.None, out result);
src\libraries\System.Private.CoreLib\src\System\IO\FileStatus.Unix.cs (20)
291internal DateTimeOffset GetCreationTime(ReadOnlySpan<char> path, bool continueOnError = false)
294internal DateTimeOffset GetCreationTime(SafeFileHandle handle, bool continueOnError = false)
297private DateTimeOffset GetCreationTime(SafeFileHandle? handle, ReadOnlySpan<char> path, bool continueOnError = false)
315internal DateTimeOffset GetLastAccessTime(ReadOnlySpan<char> path, bool continueOnError = false)
318internal DateTimeOffset GetLastAccessTime(SafeFileHandle handle, bool continueOnError = false)
321private DateTimeOffset GetLastAccessTime(SafeFileHandle? handle, ReadOnlySpan<char> path, bool continueOnError = false)
331internal void SetLastAccessTime(string path, DateTimeOffset time, bool asDirectory)
334internal void SetLastAccessTime(SafeFileHandle handle, DateTimeOffset time, bool asDirectory)
337private void SetLastAccessTime(SafeFileHandle? handle, string? path, DateTimeOffset time, bool asDirectory)
340internal DateTimeOffset GetLastWriteTime(ReadOnlySpan<char> path, bool continueOnError = false)
343internal DateTimeOffset GetLastWriteTime(SafeFileHandle handle, bool continueOnError = false)
346private DateTimeOffset GetLastWriteTime(SafeFileHandle? handle, ReadOnlySpan<char> path, bool continueOnError = false)
356internal void SetLastWriteTime(string path, DateTimeOffset time, bool asDirectory)
359internal void SetLastWriteTime(SafeFileHandle handle, DateTimeOffset time, bool asDirectory)
362internal void SetLastWriteTime(SafeFileHandle? handle, string? path, DateTimeOffset time, bool asDirectory)
365private static DateTimeOffset UnixTimeToDateTimeOffset(long seconds, long nanoseconds)
367return DateTimeOffset.FromUnixTimeSeconds(seconds).AddTicks(nanoseconds / NanosecondsPerTick);
370private unsafe void SetAccessOrWriteTimeCore(SafeFileHandle? handle, string? path, DateTimeOffset time, bool isAccessTime, bool checkCreationTime, bool asDirectory)
583private static long UnixTimeSecondsToNanoseconds(DateTimeOffset time, long seconds)
585return (time.UtcDateTime.Ticks - DateTimeOffset.UnixEpoch.Ticks - seconds * TimeSpan.TicksPerSecond) * NanosecondsPerTick;
System.Private.DataContractSerialization (7)
System.Private.Windows.Core (31)
System.Private.Windows.Core.Tests (38)
System\Value\StoringDateTimeOffset.cs (33)
8public static TheoryData<DateTimeOffset> DateTimeOffsetData => new()
10{ DateTimeOffset.Now },
11{ DateTimeOffset.UtcNow },
12{ DateTimeOffset.MaxValue },
13{ DateTimeOffset.MinValue }
18public void DateTimeOffsetImplicit(DateTimeOffset @DateTimeOffset)
21Assert.Equal(@DateTimeOffset, value.GetValue<DateTimeOffset>());
22Assert.Equal(typeof(DateTimeOffset), value.Type);
24DateTimeOffset? source = @DateTimeOffset;
26Assert.Equal(source, value.GetValue<DateTimeOffset?>());
27Assert.Equal(typeof(DateTimeOffset), value.Type);
32public void DateTimeOffsetInOut(DateTimeOffset @DateTimeOffset)
35bool success = value.TryGetValue(out DateTimeOffset result);
39Assert.Equal(@DateTimeOffset, value.GetValue<DateTimeOffset>());
40Assert.Equal(@DateTimeOffset, (DateTimeOffset)value);
45public void NullableDateTimeOffsetInDateTimeOffsetOut(DateTimeOffset @DateTimeOffset)
47DateTimeOffset? source = @DateTimeOffset;
50bool success = value.TryGetValue(out DateTimeOffset result);
54Assert.Equal(@DateTimeOffset, value.GetValue<DateTimeOffset>());
56Assert.Equal(@DateTimeOffset, (DateTimeOffset)value);
61public void DateTimeOffsetInNullableDateTimeOffsetOut(DateTimeOffset @DateTimeOffset)
63DateTimeOffset source = @DateTimeOffset;
65bool success = value.TryGetValue(out DateTimeOffset? result);
69Assert.Equal(@DateTimeOffset, (DateTimeOffset?)value);
75DateTimeOffset? source = null;
78Assert.Equal(source, value.GetValue<DateTimeOffset?>());
79Assert.False(value.GetValue<DateTimeOffset?>().HasValue);
84public void OutAsObject(DateTimeOffset @DateTimeOffset)
88Assert.Equal(typeof(DateTimeOffset), o.GetType());
89Assert.Equal(@DateTimeOffset, (DateTimeOffset)o);
91DateTimeOffset? n = @DateTimeOffset;
94Assert.Equal(typeof(DateTimeOffset), o.GetType());
95Assert.Equal(@DateTimeOffset, (DateTimeOffset)o);
System.Private.Xml (134)
System\Xml\Schema\XmlValueConverter.cs (72)
195public abstract DateTime ToDateTime(DateTimeOffset value);
198public abstract DateTimeOffset ToDateTimeOffset(DateTime value);
199public abstract DateTimeOffset ToDateTimeOffset(string value);
200public abstract DateTimeOffset ToDateTimeOffset(object value);
209public abstract string ToString(DateTimeOffset value);
322protected static readonly Type DateTimeOffsetType = typeof(DateTimeOffset);
337public override DateTime ToDateTime(DateTimeOffset value) { return (DateTime)ChangeType((object)value, DateTimeType, null); }
343public override DateTimeOffset ToDateTimeOffset(DateTime value) { return (DateTimeOffset)ChangeType((object)value, DateTimeOffsetType, null); }
344public override DateTimeOffset ToDateTimeOffset(string value) { return (DateTimeOffset)ChangeType((object)value, DateTimeOffsetType, null); }
345public override DateTimeOffset ToDateTimeOffset(object value) { return (DateTimeOffset)ChangeType((object)value, DateTimeOffsetType, null); }
375public override string ToString(DateTimeOffset value) { return (string)ChangeType((object)value, StringType, null); }
573protected static DateTimeOffset StringToDateOffset(string value)
575return (DateTimeOffset)(new XsdDateTime(value, XsdDateTimeFlags.Date));
578protected static DateTimeOffset StringToDateTimeOffset(string value)
580return (DateTimeOffset)(new XsdDateTime(value, XsdDateTimeFlags.DateTime));
583protected static DateTimeOffset StringToGDayOffset(string value)
585return (DateTimeOffset)(new XsdDateTime(value, XsdDateTimeFlags.GDay));
588protected static DateTimeOffset StringToGMonthOffset(string value)
590return (DateTimeOffset)(new XsdDateTime(value, XsdDateTimeFlags.GMonth));
593protected static DateTimeOffset StringToGMonthDayOffset(string value)
595return (DateTimeOffset)(new XsdDateTime(value, XsdDateTimeFlags.GMonthDay));
598protected static DateTimeOffset StringToGYearOffset(string value)
600return (DateTimeOffset)(new XsdDateTime(value, XsdDateTimeFlags.GYear));
603protected static DateTimeOffset StringToGYearMonthOffset(string value)
605return (DateTimeOffset)(new XsdDateTime(value, XsdDateTimeFlags.GYearMonth));
655protected static DateTimeOffset StringToTimeOffset(string value)
657return (DateTimeOffset)(new XsdDateTime(value, XsdDateTimeFlags.Time));
726protected static string DateOffsetToString(DateTimeOffset value)
731protected static string DateTimeOffsetToString(DateTimeOffset value)
736protected static string GDayOffsetToString(DateTimeOffset value)
741protected static string GMonthOffsetToString(DateTimeOffset value)
746protected static string GMonthDayOffsetToString(DateTimeOffset value)
751protected static string GYearOffsetToString(DateTimeOffset value)
756protected static string GYearMonthOffsetToString(DateTimeOffset value)
780protected static string TimeOffsetToString(DateTimeOffset value)
795internal static DateTime DateTimeOffsetToDateTime(DateTimeOffset value)
877protected static DateTimeOffset UntypedAtomicToDateTimeOffset(string value)
879return (DateTimeOffset)(new XsdDateTime(value, XsdDateTimeFlags.AllXsd));
1333public override DateTime ToDateTime(DateTimeOffset value)
1361if (sourceType == DateTimeOffsetType) return this.ToDateTime((DateTimeOffset)value);
1372public override DateTimeOffset ToDateTimeOffset(DateTime value)
1377public override DateTimeOffset ToDateTimeOffset(string value)
1394public override DateTimeOffset ToDateTimeOffset(object value)
1401if (sourceType == DateTimeOffsetType) return ((DateTimeOffset)value);
1403if (sourceType == XmlAtomicValueType) return (DateTimeOffset)((XmlAtomicValue)value).ValueAsDateTime;
1405return (DateTimeOffset)ChangeListType(value, DateTimeOffsetType, null);
1460public override string ToString(DateTimeOffset value) =>
1463XmlTypeCode.Date => DateOffsetToString((DateTimeOffset)value),
1464XmlTypeCode.Time => TimeOffsetToString((DateTimeOffset)value),
1465XmlTypeCode.GDay => GDayOffsetToString((DateTimeOffset)value),
1466XmlTypeCode.GMonth => GMonthOffsetToString((DateTimeOffset)value),
1467XmlTypeCode.GMonthDay => GMonthDayOffsetToString((DateTimeOffset)value),
1468XmlTypeCode.GYear => GYearOffsetToString((DateTimeOffset)value),
1469XmlTypeCode.GYearMonth => GYearMonthOffsetToString((DateTimeOffset)value),
1470_ => DateTimeOffsetToString((DateTimeOffset)value),
1480if (sourceType == DateTimeOffsetType) return this.ToString((DateTimeOffset)value);
1535if (sourceType == DateTimeOffsetType) return (new XmlAtomicValue(SchemaType!, (DateTimeOffset)value));
1542if (sourceType == DateTimeOffsetType) return (new XmlAtomicValue(SchemaType!, (DateTimeOffset)value));
2069public override DateTimeOffset ToDateTimeOffset(string value)
2076public override DateTimeOffset ToDateTimeOffset(object value)
2084return (DateTimeOffset)ChangeTypeWildcardDestination(value, DateTimeOffsetType, null);
2209public override string ToString(DateTimeOffset value)
2211return DateTimeOffsetToString((DateTimeOffset)value);
2243if (sourceType == DateTimeOffsetType) return DateTimeOffsetToString((DateTimeOffset)value);
2575public override DateTimeOffset ToDateTimeOffset(object value)
2581if (sourceType == XmlAtomicValueType) return (DateTimeOffset)((XmlAtomicValue)value).ValueAs(DateTimeOffsetType);
2583return (DateTimeOffset)ChangeTypeWildcardDestination(value, DateTimeOffsetType, null);
2796if (sourceType == DateTimeOffsetType) return (new XmlAtomicValue(XmlSchemaType.GetBuiltInSimpleType(XmlTypeCode.DateTime), (DateTimeOffset)value));
2986if (itemTypeDst == DateTimeOffsetType) return ToArray<DateTimeOffset>(value, nsResolver);
System\Xml\XmlConvert.cs (11)
729public static string ToString(DateTimeOffset value)
735public static string ToString(DateTimeOffset value, [StringSyntax(StringSyntaxAttribute.DateTimeFormat)] string format)
1238public static DateTimeOffset ToDateTimeOffset(string s)
1243DateTimeOffset dateTimeOffset = (DateTimeOffset)xsdDateTime;
1247public static DateTimeOffset ToDateTimeOffset(string s, [StringSyntax(StringSyntaxAttribute.DateTimeFormat)] string format)
1251return DateTimeOffset.ParseExact(s, format, DateTimeFormatInfo.InvariantInfo, DateTimeStyles.AllowLeadingWhite | DateTimeStyles.AllowTrailingWhite);
1254public static DateTimeOffset ToDateTimeOffset(string s, [StringSyntax(StringSyntaxAttribute.DateTimeFormat)] string[] formats)
1258return DateTimeOffset.ParseExact(s, formats, DateTimeFormatInfo.InvariantInfo, DateTimeStyles.AllowLeadingWhite | DateTimeStyles.AllowTrailingWhite);
1791internal static bool TryFormat(DateTimeOffset value, Span<char> destination, out int charsWritten)
1797internal static bool TryFormat(DateTimeOffset value, [StringSyntax(StringSyntaxAttribute.DateTimeFormat)] string format, Span<char> destination, out int charsWritten)
System.Private.Xml.Linq (20)
System.Runtime (1)
System.Runtime.Caching (23)
System.Runtime.InteropServices.JavaScript (4)
System.Security.Cryptography (49)
System\Security\Cryptography\X509Certificates\CertificateRequest.cs (15)
613/// Typically <see cref="DateTimeOffset.UtcNow"/>, plus or minus a few seconds.
631public X509Certificate2 CreateSelfSigned(DateTimeOffset notBefore, DateTimeOffset notAfter)
676/// Typically <see cref="DateTimeOffset.UtcNow"/>, plus or minus a few seconds.
716DateTimeOffset notBefore,
717DateTimeOffset notAfter,
734/// Typically <see cref="DateTimeOffset.UtcNow"/>, plus or minus a few seconds.
774DateTimeOffset notBefore,
775DateTimeOffset notAfter,
889/// Typically <see cref="DateTimeOffset.UtcNow"/>, plus or minus a few seconds.
916DateTimeOffset notBefore,
917DateTimeOffset notAfter,
934/// Typically <see cref="DateTimeOffset.UtcNow"/>, plus or minus a few seconds.
961DateTimeOffset notBefore,
962DateTimeOffset notAfter,
System.Security.Cryptography.Pkcs (10)
System.ServiceModel.Syndication (40)
System\ServiceModel\Syndication\DateTimeHelper.cs (10)
13public static bool DefaultRss20DateTimeParser(XmlDateTimeData XmlDateTimeData, out DateTimeOffset dateTimeOffset)
18if (DateTimeOffset.TryParse(dateTimeString, out dateTimeOffset))
38public static bool DefaultAtom10DateTimeParser(XmlDateTimeData XmlDateTimeData, out DateTimeOffset dateTimeOffset)
43private static bool Rfc3339DateTimeParser(string dateTimeString, out DateTimeOffset dto)
45dto = default(DateTimeOffset);
68return DateTimeOffset.TryParseExact(dateTimeString, Rfc3339DateTimeFormat, CultureInfo.InvariantCulture.DateTimeFormat, DateTimeStyles.None, out dto);
71private static bool Rfc822DateTimeParser(string dateTimeString, out DateTimeOffset dto)
73dto = default(DateTimeOffset);
92DateTimeOffset theTime;
119if (DateTimeOffset.TryParseExact(wellFormattedString, parseFormat,
System\ServiceModel\Syndication\SyndicationFeed.cs (5)
25private DateTimeOffset _lastUpdatedTime;
42: this(title, description, feedAlternateLink, null, DateTimeOffset.MinValue, items)
46public SyndicationFeed(string title, string description, Uri feedAlternateLink, string id, DateTimeOffset lastUpdatedTime)
51public SyndicationFeed(string title, string description, Uri feedAlternateLink, string id, DateTimeOffset lastUpdatedTime, IEnumerable<SyndicationItem> items)
150public DateTimeOffset LastUpdatedTime
System\ServiceModel\Syndication\SyndicationItem.cs (7)
18private DateTimeOffset _lastUpdatedTime;
20private DateTimeOffset _publishDate;
27: this(title, content, itemAlternateLink, null, DateTimeOffset.MinValue)
31public SyndicationItem(string title, string content, Uri itemAlternateLink, string id, DateTimeOffset lastUpdatedTime)
36public SyndicationItem(string title, SyndicationContent content, Uri itemAlternateLink, string id, DateTimeOffset lastUpdatedTime)
104public DateTimeOffset LastUpdatedTime
129public DateTimeOffset PublishDate
System.Text.Json (88)
System\Text\Json\Writer\Utf8JsonWriter.WriteProperties.DateTimeOffset.cs (23)
13/// Writes the pre-encoded property name and <see cref="DateTimeOffset"/> value (as a JSON string) as part of a name/value pair of a JSON object.
21/// Writes the <see cref="DateTimeOffset"/> using the round-trippable ('O') <see cref="StandardFormat"/> , for example: 2017-06-12T05:30:45.7680000-07:00.
23public void WriteString(JsonEncodedText propertyName, DateTimeOffset value)
35/// Writes the property name and <see cref="DateTimeOffset"/> value (as a JSON string) as part of a name/value pair of a JSON object.
49/// Writes the <see cref="DateTimeOffset"/> using the round-trippable ('O') <see cref="StandardFormat"/> , for example: 2017-06-12T05:30:45.7680000-07:00.
52public void WriteString(string propertyName, DateTimeOffset value)
59/// Writes the property name and <see cref="DateTimeOffset"/> value (as a JSON string) as part of a name/value pair of a JSON object.
70/// Writes the <see cref="DateTimeOffset"/> using the round-trippable ('O') <see cref="StandardFormat"/> , for example: 2017-06-12T05:30:45.7680000-07:00.
73public void WriteString(ReadOnlySpan<char> propertyName, DateTimeOffset value)
84/// Writes the property name and <see cref="DateTimeOffset"/> value (as a JSON string) as part of a name/value pair of a JSON object.
95/// Writes the <see cref="DateTimeOffset"/> using the round-trippable ('O') <see cref="StandardFormat"/> , for example: 2017-06-12T05:30:45.7680000-07:00.
98public void WriteString(ReadOnlySpan<byte> utf8PropertyName, DateTimeOffset value)
108private void WriteStringEscape(ReadOnlySpan<char> propertyName, DateTimeOffset value)
124private void WriteStringEscape(ReadOnlySpan<byte> utf8PropertyName, DateTimeOffset value)
140private void WriteStringEscapeProperty(ReadOnlySpan<char> propertyName, DateTimeOffset value, int firstEscapeIndexProp)
163private void WriteStringEscapeProperty(ReadOnlySpan<byte> utf8PropertyName, DateTimeOffset value, int firstEscapeIndexProp)
186private void WriteStringByOptions(ReadOnlySpan<char> propertyName, DateTimeOffset value)
199private void WriteStringByOptions(ReadOnlySpan<byte> utf8PropertyName, DateTimeOffset value)
212private void WriteStringMinimized(ReadOnlySpan<char> escapedPropertyName, DateTimeOffset value)
246private void WriteStringMinimized(ReadOnlySpan<byte> escapedPropertyName, DateTimeOffset value)
280private void WriteStringIndented(ReadOnlySpan<char> escapedPropertyName, DateTimeOffset value)
329private void WriteStringIndented(ReadOnlySpan<byte> escapedPropertyName, DateTimeOffset value)
378internal void WritePropertyName(DateTimeOffset value)
System.Text.Json.SourceGeneration (1)
System.Windows.Forms.Tests (3)
System.Windows.Forms.UI.IntegrationTests (4)
System.Xaml (4)
System.Xaml.Tests (16)
System\Xaml\Replacements\DateTimeOffsetConverter2Tests.cs (16)
24var type = new XamlType(typeof(DateTimeOffset), new XamlSchemaContext());
31DateTimeOffset dateTimeOffset = new DateTimeOffset(2018, 12, 9, 1, 2, 3, 4, TimeSpan.FromMinutes(10));
39public void ConvertFrom_String_ReturnsExpected(string value, CultureInfo culture, DateTimeOffset expected)
41var type = new XamlType(typeof(DateTimeOffset), new XamlSchemaContext());
51var type = new XamlType(typeof(DateTimeOffset), new XamlSchemaContext());
63var type = new XamlType(typeof(DateTimeOffset), new XamlSchemaContext());
70yield return new object?[] { DateTimeOffset.MinValue, null };
76public void ConvertTo_DateTimeOffset_ReturnsExpected(DateTimeOffset dateTimeOffset, CultureInfo culture)
78var type = new XamlType(typeof(DateTimeOffset), new XamlSchemaContext());
86var dateTimeOffset = new DateTimeOffset(2018, 12, 9, 1, 2, 3, 4, TimeSpan.FromMinutes(10));
87var type = new XamlType(typeof(DateTimeOffset), new XamlSchemaContext());
101var type = new XamlType(typeof(DateTimeOffset), new XamlSchemaContext());
110var type = new XamlType(typeof(DateTimeOffset), new XamlSchemaContext());
112Assert.Throws<NotSupportedException>(() => converter.ConvertTo(DateTimeOffset.MinValue, destinationType));
118var type = new XamlType(typeof(DateTimeOffset), new XamlSchemaContext());
120Assert.Throws<ArgumentNullException>("destinationType", () => converter.ConvertTo(DateTimeOffset.MinValue, null!));
TagHelpersWebSite (1)
Templates.Blazor.Tests (9)
Templates.Blazor.WebAssembly.Auth.Tests (9)
Templates.Blazor.WebAssembly.Tests (9)
Templates.Mvc.Tests (9)
Templates.Tests (9)
TestProject.WorkerA (1)
WebTransportInteractiveSampleApp (3)
WebTransportSampleApp (3)
xunit.assert (8)