Table of Contents

Class Timestamp

Namespace
GenerativeAI.Types
Assembly
GenerativeAI.dll

A Timestamp represents a point in time independent of any time zone or calendar, represented as seconds and fractions of seconds at nanosecond resolution in UTC Epoch time.

[JsonConverter(typeof(TimestampJsonConverter))]
public class Timestamp
Inheritance
Timestamp
Inherited Members
Extension Methods

Properties

Nanos

Non-negative fractions of a second at nanosecond resolution. Negative second values with fractions must still have non-negative nanos values that count forward in time. Must be from 0 to 999,999,999 inclusive.

public int Nanos { get; set; }

Property Value

int

Seconds

Represents seconds of UTC time since Unix epoch 1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59Z inclusive.

public long Seconds { get; set; }

Property Value

long

Methods

FromDateTime(DateTime)

Creates a new Timestamp object from a DateTime object.

public static Timestamp FromDateTime(DateTime dateTime)

Parameters

dateTime DateTime

The DateTime object to convert.

Returns

Timestamp

The new Timestamp object.

ToDateTime()

Converts this Timestamp object to a DateTime object.

public DateTime ToDateTime()

Returns

DateTime

The converted DateTime object.

Operators

implicit operator DateTime(Timestamp)

Implicitly converts a Timestamp object to a DateTime object.

public static implicit operator DateTime(Timestamp timestamp)

Parameters

timestamp Timestamp

The Timestamp object to convert.

Returns

DateTime

implicit operator Timestamp(DateTime)

Implicitly converts a DateTime object to a Timestamp object.

public static implicit operator Timestamp(DateTime dateTime)

Parameters

dateTime DateTime

The DateTime object to convert.

Returns

Timestamp

See Also