GoDuration 0.1.0
See the version list below for details.
dotnet add package GoDuration --version 0.1.0
NuGet\Install-Package GoDuration -Version 0.1.0
<PackageReference Include="GoDuration" Version="0.1.0" />
<PackageVersion Include="GoDuration" Version="0.1.0" />
<PackageReference Include="GoDuration" />
paket add GoDuration --version 0.1.0
#r "nuget: GoDuration, 0.1.0"
#:package GoDuration@0.1.0
#addin nuget:?package=GoDuration&version=0.1.0
#tool nuget:?package=GoDuration&version=0.1.0
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 | Versions 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. |
-
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.