Table of Contents

Struct Time

Namespace
Sdl3Sharp.Timing
Assembly
Sdl3Sharp.dll
public readonly struct Time : IComparable, IComparable<Time>, IEquatable<Time>, ISpanFormattable, IFormattable, IComparisonOperators<Time, Time, bool>, IEqualityOperators<Time, Time, bool>
Implements
Inherited Members

Constructors

Time(long)

public Time(long nanosecondsSinceUnixEpoch)

Parameters

nanosecondsSinceUnixEpoch long

Fields

MicrosecondsPerSecond

public const long MicrosecondsPerSecond = 1000000

Field Value

long

MillisecondsPerSecond

public const long MillisecondsPerSecond = 1000

Field Value

long

NanosecondsPerMicrosecond

public const long NanosecondsPerMicrosecond = 1000

Field Value

long

NanosecondsPerMillisecond

public const long NanosecondsPerMillisecond = 1000000

Field Value

long

NanosecondsPerSecond

public const long NanosecondsPerSecond = 1000000000

Field Value

long

Properties

NanosecondsSinceUnixEpoch

public long NanosecondsSinceUnixEpoch { get; }

Property Value

long

Methods

CompareTo(Time)

Compares the current instance with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other object.

public int CompareTo(Time other)

Parameters

other Time

An object to compare with this instance.

Returns

int

A value that indicates the relative order of the objects being compared. The return value has these meanings:

Value Meaning
Less than zero This instance precedes other in the sort order.
Zero This instance occurs in the same position in the sort order as other.
Greater than zero This instance follows other in the sort order.

CompareTo(object?)

Compares the current instance with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other object.

public int CompareTo(object? obj)

Parameters

obj object

An object to compare with this instance.

Returns

int

A value that indicates the relative order of the objects being compared. The return value has these meanings:

Value Meaning
Less than zero This instance precedes obj in the sort order.
Zero This instance occurs in the same position in the sort order as obj.
Greater than zero This instance follows obj in the sort order.

Exceptions

ArgumentException

obj is not the same type as this instance.

Equals(Time)

Indicates whether the current object is equal to another object of the same type.

public bool Equals(Time other)

Parameters

other Time

An object to compare with this object.

Returns

bool

true if the current object is equal to the other parameter; otherwise, false.

Equals(object?)

Indicates whether this instance and a specified object are equal.

public override bool Equals(object? obj)

Parameters

obj object

The object to compare with the current instance.

Returns

bool

true if obj and this instance are the same type and represent the same value; otherwise, false.

FromPosixTime(long, long)

public static Time FromPosixTime(long seconds, long nanoseconds)

Parameters

seconds long
nanoseconds long

Returns

Time

FromWindowsFileTime(long)

public static Time FromWindowsFileTime(long fileTime)

Parameters

fileTime long

Returns

Time

GetHashCode()

Returns the hash code for this instance.

public override int GetHashCode()

Returns

int

A 32-bit signed integer that is the hash code for this instance.

MicrosecondsToNanoseconds(long)

public static long MicrosecondsToNanoseconds(long microseconds)

Parameters

microseconds long

Returns

long

MillisecondsToNanoseconds(long)

public static long MillisecondsToNanoseconds(long milliseconds)

Parameters

milliseconds long

Returns

long

NanosecondsToSeconds(long)

public static (long seconds, int milliseconds, int microseconds, int nanoseconds) NanosecondsToSeconds(long nanoseconds)

Parameters

nanoseconds long

Returns

(long seconds, int milliseconds, int microseconds, int nanoseconds)

NanosecondsToWholeMicroseconds(long)

public static long NanosecondsToWholeMicroseconds(long nanoseconds)

Parameters

nanoseconds long

Returns

long

NanosecondsToWholeMilliseconds(long)

public static long NanosecondsToWholeMilliseconds(long nanoseconds)

Parameters

nanoseconds long

Returns

long

NanosecondsToWholeSeconds(long)

public static long NanosecondsToWholeSeconds(long nanoseconds)

Parameters

nanoseconds long

Returns

long

SecondsToNanoseconds(long)

public static long SecondsToNanoseconds(long seconds)

Parameters

seconds long

Returns

long

ToPosixTime()

public (long seconds, long nanoseconds) ToPosixTime()

Returns

(long seconds, long nanoseconds)

ToString()

Returns the fully qualified type name of this instance.

public override string ToString()

Returns

string

The fully qualified type name.

ToString(IFormatProvider?)

public string ToString(IFormatProvider? formatProvider)

Parameters

formatProvider IFormatProvider

Returns

string

ToString(string?)

public string ToString(string? format)

Parameters

format string

Returns

string

ToString(string?, IFormatProvider?)

Formats the value of the current instance using the specified format.

public string ToString(string? format, IFormatProvider? formatProvider)

Parameters

format string

The format to use.

-or-

A null reference (Nothing in Visual Basic) to use the default format defined for the type of the IFormattable implementation.

formatProvider IFormatProvider

The provider to use to format the value.

-or-

A null reference (Nothing in Visual Basic) to obtain the numeric format information from the current locale setting of the operating system.

Returns

string

The value of the current instance in the specified format.

ToWindowFileTime()

public long ToWindowFileTime()

Returns

long

TryConvertFromDateTime(in DateTime, out Time)

public static bool TryConvertFromDateTime(in DateTime dateTime, out Time time)

Parameters

dateTime DateTime
time Time

Returns

bool

TryConvertToDateTime(out DateTime, bool)

public bool TryConvertToDateTime(out DateTime dateTime, bool convertToLocalTime = true)

Parameters

dateTime DateTime
convertToLocalTime bool

Returns

bool

TryFormat(Span<char>, out int, ReadOnlySpan<char>, IFormatProvider?)

Tries to format the value of the current instance into the provided span of characters.

public bool TryFormat(Span<char> destination, out int charsWritten, ReadOnlySpan<char> format = default, IFormatProvider? provider = null)

Parameters

destination Span<char>

The span in which to write this instance's value formatted as a span of characters.

charsWritten int

When this method returns, contains the number of characters that were written in destination.

format ReadOnlySpan<char>

A span containing the characters that represent a standard or custom format string that defines the acceptable format for destination.

provider IFormatProvider

An optional object that supplies culture-specific formatting information for destination.

Returns

bool

true if the formatting was successful; otherwise, false.

TryGetCurrentTime(out Time)

public static bool TryGetCurrentTime(out Time time)

Parameters

time Time

Returns

bool

Operators

operator ==(Time, Time)

Compares two values to determine equality.

public static bool operator ==(Time left, Time right)

Parameters

left Time

The value to compare with right.

right Time

The value to compare with left.

Returns

bool

true if left is equal to right; otherwise, false.

operator >(Time, Time)

Compares two values to determine which is greater.

public static bool operator >(Time left, Time right)

Parameters

left Time

The value to compare with right.

right Time

The value to compare with left.

Returns

bool

true if left is greater than right; otherwise, false.

operator >=(Time, Time)

Compares two values to determine which is greater or equal.

public static bool operator >=(Time left, Time right)

Parameters

left Time

The value to compare with right.

right Time

The value to compare with left.

Returns

bool

true if left is greater than or equal to right; otherwise, false.

operator !=(Time, Time)

Compares two values to determine inequality.

public static bool operator !=(Time left, Time right)

Parameters

left Time

The value to compare with right.

right Time

The value to compare with left.

Returns

bool

true if left is not equal to right; otherwise, false.

operator <(Time, Time)

Compares two values to determine which is less.

public static bool operator <(Time left, Time right)

Parameters

left Time

The value to compare with right.

right Time

The value to compare with left.

Returns

bool

true if left is less than right; otherwise, false.

operator <=(Time, Time)

Compares two values to determine which is less or equal.

public static bool operator <=(Time left, Time right)

Parameters

left Time

The value to compare with right.

right Time

The value to compare with left.

Returns

bool

true if left is less than or equal to right; otherwise, false.