Show / Hide Table of Contents

Class Duration

Parsing and stringifying of a TimeSpan according to IPFS.

Inheritance
Object
Duration
Inherited Members
Object.Equals(Object)
Object.Equals(Object, Object)
Object.GetHashCode()
Object.GetType()
Object.MemberwiseClone()
Object.ReferenceEquals(Object, Object)
Object.ToString()
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 Source

Parse(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 s.

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

s is not a valid IPFS duration.

| Improve this Doc View Source

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 duration is equal to Zero/

Returns
Type Description
String

The IPFS duration string representation.

  • Improve this Doc
  • View Source
Back to top Generated by DocFX