GoDuration 0.1.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package GoDuration --version 0.1.0
                    
NuGet\Install-Package GoDuration -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" Version="0.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="GoDuration" Version="0.1.0" />
                    
Directory.Packages.props
<PackageReference Include="GoDuration" />
                    
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 --version 0.1.0
                    
#r "nuget: GoDuration, 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@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&version=0.1.0
                    
Install as a Cake Addin
#tool nuget:?package=GoDuration&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.
  • net10.0

    • No dependencies.

NuGet packages (4)

Showing the top 4 NuGet packages that depend on GoDuration:

Package Downloads
GoDuration.SystemTextJson

System.Text.Json TimeSpan converter that reads and writes Go-style duration strings (e.g. "300ms", "1h30m") through the GoDuration parser and formatter.

GoDuration.NewtonsoftJson

Newtonsoft.Json TimeSpan converter that reads and writes Go-style duration strings (e.g. "300ms", "1h30m") through the GoDuration parser and formatter.

GoDuration.YamlDotNet

YamlDotNet TimeSpan type converter that reads and writes Go-style duration strings (e.g. "300ms", "1h30m") through the GoDuration parser and formatter.

GoDuration.NodaTime

Parses and formats Go-style duration strings (e.g. "300ms", "-1.5h", "2h45m") to and from NodaTime.Duration through the GoDuration parser and formatter.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.3.0 116 8/27/2026
0.2.0 301 8/27/2026
0.1.0 118 8/27/2026