Table of Contents

Class Duration

Namespace
GenerativeAI.Types
Assembly
GenerativeAI.dll

A Duration represents a signed, fixed-length span of time represented as a count of seconds and fractions of seconds at nanosecond resolution.

[JsonConverter(typeof(DurationJsonConverter))]
public class Duration
Inheritance
Duration
Inherited Members
Extension Methods

Properties

Nanos

Signed fractions of a second at nanosecond resolution of the span of time. Durations less than one second are represented with a 0 Seconds field and a positive or negative Nanos field. For durations of one second or more, a non-zero value for the Nanos field must be of the same sign as the Seconds field. Must be from -999,999,999 to +999,999,999 inclusive.

public int Nanos { get; set; }

Property Value

int

Seconds

Signed seconds of the span of time. Must be from -315,576,000,000 to +315,576,000,000 inclusive.

public long Seconds { get; set; }

Property Value

long

Methods

FromTimeSpan(TimeSpan)

Creates a new Duration object from a TimeSpan object.

public static Duration FromTimeSpan(TimeSpan timeSpan)

Parameters

timeSpan TimeSpan

The TimeSpan object to convert.

Returns

Duration

The new Duration object.

ToTimeSpan()

Converts this Duration object to a TimeSpan object.

public TimeSpan ToTimeSpan()

Returns

TimeSpan

The converted TimeSpan object.

Operators

implicit operator TimeSpan(Duration)

Implicitly converts a Duration object to a TimeSpan object.

public static implicit operator TimeSpan(Duration duration)

Parameters

duration Duration

The Duration object to convert.

Returns

TimeSpan

implicit operator Duration(TimeSpan)

Implicitly converts a TimeSpan object to a Duration object.

public static implicit operator Duration(TimeSpan timeSpan)

Parameters

timeSpan TimeSpan

The TimeSpan object to convert.

Returns

Duration

See Also