GoDuration.SystemTextJson 0.1.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package GoDuration.SystemTextJson --version 0.1.0
                    
NuGet\Install-Package GoDuration.SystemTextJson -Version 0.1.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="GoDuration.SystemTextJson" Version="0.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="GoDuration.SystemTextJson" Version="0.1.0" />
                    
Directory.Packages.props
<PackageReference Include="GoDuration.SystemTextJson" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add GoDuration.SystemTextJson --version 0.1.0
                    
#r "nuget: GoDuration.SystemTextJson, 0.1.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.
#:package GoDuration.SystemTextJson@0.1.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=GoDuration.SystemTextJson&version=0.1.0
                    
Install as a Cake Addin
#tool nuget:?package=GoDuration.SystemTextJson&version=0.1.0
                    
Install as a Cake Tool

GoDuration

A C# library that parses Go-style duration strings into TimeSpan values, and formats TimeSpan values back to Go-style duration strings.

Packages

Package Purpose
GoDuration Core parser and formatter.
GoDuration.SystemTextJson TimeSpan converter for System.Text.Json.
GoDuration.NewtonsoftJson TimeSpan converter for Newtonsoft.Json.
GoDuration.YamlDotNet TimeSpan type converter for YamlDotNet.

Use

using GoDuration;

TimeSpan value = Duration.Parse("1h30m45s");
string text = Duration.Format(value);

The parser accepts the same units as Go: ns, us, µs, μs, ms, s, m, and h.

Format options

Use DurationFormatOptions to change the output format:

var options = new DurationFormatOptions
{
    OmitZeroUnits = true,
    IncludePositiveSign = true,
    MicrosecondSymbol = MicrosecondSymbol.Ascii,
};

string text = Duration.Format(TimeSpan.FromHours(1), options);

Build

The build uses Fallout. Run one of the scripts at the repository root:

./build.sh Test
./build.sh Pack

Targets: Clean, Restore, Compile, Test, Pack, BundleZip, PublishNuGet, PublishGitHubRelease, Publish.

License

MIT. See LICENSE.

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.2.0 110 8/27/2026 0.2.0 is deprecated because it is no longer maintained.
0.1.0 100 8/27/2026