![]() |
VOOZH | about |
dotnet add package Portable.System.DateTimeOnly --version 9.0.1
NuGet\Install-Package Portable.System.DateTimeOnly -Version 9.0.1
<PackageReference Include="Portable.System.DateTimeOnly" Version="9.0.1" />
<PackageVersion Include="Portable.System.DateTimeOnly" Version="9.0.1" />Directory.Packages.props
<PackageReference Include="Portable.System.DateTimeOnly" />Project file
paket add Portable.System.DateTimeOnly --version 9.0.1
#r "nuget: Portable.System.DateTimeOnly, 9.0.1"
#:package Portable.System.DateTimeOnly@9.0.1
#addin nuget:?package=Portable.System.DateTimeOnly&version=9.0.1Install as a Cake Addin
#tool nuget:?package=Portable.System.DateTimeOnly&version=9.0.1Install as a Cake Tool
👁 Build
👁 Codacy Grade
👁 Codacy Coverage
👁 PVS-Studio
👁 Sponsors
The .NET 6 introduced two new data types System.DateOnly and System.TimeOnly that can be used in various scenarios. If you want to use the same types in the .NET versions below to .NET 6 you can use this library in form of the NuGet package. You can also use it in your own NuGet package if you want to provide an API that uses these types and make it compatible with all currently supported .NET versions at the same time.
The original version of this package used the simplified string parsing approach - it just reuses the default System.DateTime parsing logic as is. It works well in most use cases but parsing behavior was not matched 100% to the .NET 6 System.DateOnly and System.TimeOnly data types. Their raise the System.FormatException exception in case if the input string contains the time part for the System.DateOnly or the date part in the case of System.TimeOnly types.
Unfortunately, this behavior in .NET 6 implementation depends heavily on an internal parser that provides a lot more information about parsing results than a public version of parsing API. Porting this parser required porting a lot of culture-specific code and looks unpractical for such a simple package. So another approach selected for solving this issue - double parsing using System.DateTime.TryParseExact method with proper formatting strings.
This approach, of course, has an obvious disadvantage - in some cases, we have to parse the same string twice. If performance is critical for you and you are OK with the incorrect parsing results in some rare cases you can restore the original behavior using the application context switch named Portable.System.DateTimeOnly.UseFastParsingLogic. Check the FastStrictParsingLogicTests for more examples for this issue.
System.Text.Json SupportYou can use helper NuGet package Portable.System.DateTimeOnly.Json with the System.Text.Json for enabling cross-framework JSON serialization of System.DateOnly and System.TimeOnly data types in your code.
Thanks a lot for all contributors. See the full list of project supporters in the CONTRIBUTORS file.
This project uses PVS-Studio - static analyzer for C, C++, C#, and Java code.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 net5.0 was computed. net5.0-windows net5.0-windows was computed. net6.0 net6.0 is compatible. net6.0-android net6.0-android was computed. net6.0-ios net6.0-ios was computed. net6.0-maccatalyst net6.0-maccatalyst was computed. net6.0-macos net6.0-macos was computed. net6.0-tvos net6.0-tvos was computed. net6.0-windows net6.0-windows was computed. net7.0 net7.0 was computed. net7.0-android net7.0-android was computed. net7.0-ios net7.0-ios was computed. net7.0-maccatalyst net7.0-maccatalyst was computed. net7.0-macos net7.0-macos was computed. net7.0-tvos net7.0-tvos was computed. net7.0-windows net7.0-windows was computed. net8.0 net8.0 was computed. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net9.0 net9.0 was computed. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 was computed. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 netcoreapp2.0 was computed. netcoreapp2.1 netcoreapp2.1 was computed. netcoreapp2.2 netcoreapp2.2 was computed. netcoreapp3.0 netcoreapp3.0 was computed. netcoreapp3.1 netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 netstandard2.0 is compatible. netstandard2.1 netstandard2.1 is compatible. |
| .NET Framework | net461 net461 was computed. net462 net462 is compatible. net463 net463 was computed. net47 net47 was computed. net471 net471 was computed. net472 net472 was computed. net48 net48 was computed. net481 net481 was computed. |
| MonoAndroid | monoandroid monoandroid was computed. |
| MonoMac | monomac monomac was computed. |
| MonoTouch | monotouch monotouch was computed. |
| Tizen | tizen40 tizen40 was computed. tizen60 tizen60 was computed. |
| Xamarin.iOS | xamarinios xamarinios was computed. |
| Xamarin.Mac | xamarinmac xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos xamarinwatchos was computed. |
Showing the top 5 NuGet packages that depend on Portable.System.DateTimeOnly:
| Package | Downloads |
|---|---|
|
Auth0.ManagementApi
Package Description |
|
|
Ical.Net
The most popular iCalendar (RFC 5545) class library for .NET. |
|
|
AvroConvert
Rapid Apache Avro serializer for .NET. |
|
|
ShopifySharp
ShopifySharp is a C# and .NET library that helps developers easily authenticate with and manage Shopify stores. |
|
|
Square
Use Square APIs to manage and run business including payment, customer, product, inventory, and employee management. |
Showing the top 10 popular GitHub repositories that depend on Portable.System.DateTimeOnly:
| Repository | Stars |
|---|---|
|
riok/mapperly
A .NET source generator for generating object mappings. No runtime reflection.
|
|
|
ical-org/ical.net
iCal.NET - iCalendar library for .Net
|
|
|
nozzlegear/ShopifySharp
ShopifySharp is a .NET library that helps developers easily authenticate with and manage Shopify stores using Shopify's GraphQL API.
|
|
|
riganti/dotvvm
Open source MVVM framework for Web Apps
|
|
|
xoofx/Tomlyn
Tomlyn is a TOML parser, validator and authoring library for .NET Framework and .NET Core
|
|
|
auth0/auth0.net
.NET client for the Auth0 Authentication & Management APIs.
|
|
|
byme8/ZeroQL
C# GraphQL client with Linq-like syntax
|
|
|
alpacahq/alpaca-trade-api-csharp
C# SDK for Alpaca Trade API https://docs.alpaca.markets/
|
|
|
YAXLib/YAXLib
Yet Another XML Serialization Library for the .NET Framework and .NET Core
|
|
|
AdrianStrugala/AvroConvert
Rapid Avro serializer for C# .NET
|
| Version | Downloads | Last Updated | |
|---|---|---|---|
| 9.0.1 | 849,018 | 9/6/2025 | |
| 9.0.0 | 446,927 | 1/10/2025 | |
| 9.0.0-beta1 | 606 | 11/16/2024 | 9.0.0-beta1 is deprecated because it is no longer maintained. |
| 8.0.2 | 414,221 | 11/14/2024 | |
| 8.0.1 | 867,825 | 5/5/2024 | |
| 8.0.0 | 379,395 | 11/16/2023 | |
| 7.0.1 | 273,434 | 3/11/2023 | |
| 7.0.0 | 37,426 | 1/2/2023 | |
| 6.0.3 | 57,224 | 11/21/2022 | |
| 6.0.2 | 251,528 | 7/20/2022 | |
| 6.0.1 | 22,717 | 3/6/2022 |
- The `System.Memory` package was upgraded from version 4.6.0 to version 4.6.3 for better compatibility.