Portable.System.DateTimeOnly 7.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package Portable.System.DateTimeOnly --version 7.0.0                
NuGet\Install-Package Portable.System.DateTimeOnly -Version 7.0.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Portable.System.DateTimeOnly" Version="7.0.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Portable.System.DateTimeOnly --version 7.0.0                
#r "nuget: Portable.System.DateTimeOnly, 7.0.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Portable.System.DateTimeOnly as a Cake Addin
#addin nuget:?package=Portable.System.DateTimeOnly&version=7.0.0

// Install Portable.System.DateTimeOnly as a Cake Tool
#tool nuget:?package=Portable.System.DateTimeOnly&version=7.0.0                

Build Codacy Codacy Nuget Nuget Sponsors

Logo Portable.System.DateTimeOnly

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.

String Parsing Performance

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.

Contributors

Thanks a lot for all contributors. See the full list of project supporters in the CONTRIBUTORS file.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 is compatible. 
.NET Framework net461 was computed.  net462 is compatible.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETFramework 4.6.2

  • .NETStandard 2.0

  • .NETStandard 2.1

    • No dependencies.
  • net6.0

    • No dependencies.

NuGet packages (48)

Showing the top 5 NuGet packages that depend on Portable.System.DateTimeOnly:

Package Downloads
AvroConvert

Rapid Apache Avro serializer for .NET.

YAXLib

YAXLib is an XML Serialization library which allows the programmer to structure freely the XML result, choose the fields to serialize (public, non-public properties, or member variables), serialize all known generic and non-generic collections, serialize different kinds of arrays (single-dimensional, multi-dimensional, jagged arrays), serialize objects through a reference to their base-class or interface (polymorphic serialization), define custom serializers, add comments for the elements in the XML result, serialize as CDATA or Base64-encoded, strip invalid XML characters, and much more..

Hochfrequenz.BO4Enet

Package Description

DotVVM

DotVVM is an open source ASP.NET-based framework which allows to build interactive web apps easily by using mostly C# and HTML.

Alpaca.Markets

C# SDK for Alpaca Trade API https://docs.alpaca.markets/

GitHub repositories (8)

Showing the top 5 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
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
byme8/ZeroQL
C# GraphQL client with Linq-like syntax
Version Downloads Last updated
9.0.0-beta1 269 11/16/2024
8.0.2 10,239 11/14/2024
8.0.1 139,673 5/5/2024
8.0.0 140,462 11/16/2023
7.0.1 134,693 3/11/2023
7.0.0 28,703 1/2/2023
6.0.3 22,604 11/21/2022
6.0.2 110,341 7/20/2022
6.0.1 18,554 3/6/2022
6.0.0 9,556 1/6/2022

- The .NET 5 and .NET Framework 4.6.1 TFMs were removed from the target frameworks list - the .NET Standard 2.1 binaries will be used by NuGet.
- Backported `DateOnly` and `TimeOnly` sources from .NET 7 code base (release version branch) and adopted them for target frameworks.