Class Duration
Parsing and stringifying of a TimeSpan according to IPFS.
Inherited Members
Namespace: Ipfs
Assembly: Ipfs.Core.dll
Syntax
public static class Duration
Remarks
From the go spec.
A duration string is a possibly signed sequence of decimal numbers, each with optional fraction and a unit suffix, such as "300ms", "-1.5h" or "2h45m". Valid time units are "ns", "us" (or "µs"), "ms", "s", "m", "h".
Methods
| Improve this Doc View SourceParse(String)
Converts the string representation of an IPFS duration into its TimeSpan equivalent.
Declaration
public static TimeSpan Parse(string s)
Parameters
| Type | Name | Description |
|---|---|---|
| String | s | A string that contains the duration to convert. |
Returns
| Type | Description |
|---|---|
| TimeSpan | A TimeSpan that is equivalent to |
Remarks
An empty string or "n/a" or "unknown" returns Zero.
A duration string is a possibly signed sequence of decimal numbers, each with optional fraction and a unit suffix, such as "300ms", "-1.5h" or "2h45m". Valid time units are "ns", "us" (or "µs"), "ms", "s", "m", "h".
Exceptions
| Type | Condition |
|---|---|
| FormatException |
|
Stringify(TimeSpan, String)
Converts the TimeSpan to the equivalent string representation of an IPFS duration.
Declaration
public static string Stringify(TimeSpan duration, string zeroValue = "0s")
Parameters
| Type | Name | Description |
|---|---|---|
| TimeSpan | duration | The TimeSpan to convert. |
| String | zeroValue | The string representation, when the |
Returns
| Type | Description |
|---|---|
| String | The IPFS duration string representation. |