Table of Contents

Struct DateOrNanoseconds

Namespace
MassiveDotNet
Assembly
MassiveDotNet.dll

A point in time accepted by the tick-level Massive endpoints that take "either a date with the format YYYY-MM-DD or a nanosecond timestamp".

public readonly struct DateOrNanoseconds : IEquatable<DateOrNanoseconds>
Implements
Inherited Members

Remarks

This is DateOrTimestamp with the unit changed. The two are separate types with the unit in the name because an Instant converts implicitly to either, and a millisecond render on a nanosecond endpoint would compile and ask for a moment in 1970 (decision D20). The map chooses the type each endpoint documents.

Implicit conversions exist from LocalDate, Instant, long, and string, so callers can pass whichever form they already have without converting by hand.

Methods

Equals(DateOrNanoseconds)

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

public bool Equals(DateOrNanoseconds other)

Parameters

other DateOrNanoseconds

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.

FromDate(LocalDate)

Creates a value from a calendar date, rendered as YYYY-MM-DD.

public static DateOrNanoseconds FromDate(LocalDate value)

Parameters

value LocalDate

The calendar date.

Returns

DateOrNanoseconds

The wrapped value.

FromInstant(Instant)

Creates a value from an instant, rendered as Unix nanoseconds.

public static DateOrNanoseconds FromInstant(Instant value)

Parameters

value Instant

The instant.

Returns

DateOrNanoseconds

The wrapped value.

FromLiteral(string)

Creates a value from a literal already in a form the API accepts.

public static DateOrNanoseconds FromLiteral(string value)

Parameters

value string

The literal value, such as "2026-01-15".

Returns

DateOrNanoseconds

The wrapped value.

Exceptions

ArgumentException

value is null or whitespace.

FromUnixNanoseconds(long)

Creates a value from a Unix nanosecond timestamp.

public static DateOrNanoseconds FromUnixNanoseconds(long epochNanoseconds)

Parameters

epochNanoseconds long

Nanoseconds since the Unix epoch.

Returns

DateOrNanoseconds

The wrapped value.

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.

ToString()

Renders the value in the form the API expects.

public override string ToString()

Returns

string

Either a YYYY-MM-DD date or a Unix nanosecond timestamp.

Operators

operator ==(DateOrNanoseconds, DateOrNanoseconds)

Compares two values for equality.

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

Parameters

left DateOrNanoseconds

The left value.

right DateOrNanoseconds

The right value.

Returns

bool

true when the values are equal.

implicit operator DateOrNanoseconds(Instant)

Converts an instant.

public static implicit operator DateOrNanoseconds(Instant value)

Parameters

value Instant

The instant.

Returns

DateOrNanoseconds

implicit operator DateOrNanoseconds(LocalDate)

Converts a calendar date.

public static implicit operator DateOrNanoseconds(LocalDate value)

Parameters

value LocalDate

The calendar date.

Returns

DateOrNanoseconds

implicit operator DateOrNanoseconds(long)

Converts a Unix nanosecond timestamp.

public static implicit operator DateOrNanoseconds(long value)

Parameters

value long

Nanoseconds since the Unix epoch.

Returns

DateOrNanoseconds

implicit operator DateOrNanoseconds(string)

Converts a literal value.

public static implicit operator DateOrNanoseconds(string value)

Parameters

value string

The literal value.

Returns

DateOrNanoseconds

operator !=(DateOrNanoseconds, DateOrNanoseconds)

Compares two values for inequality.

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

Parameters

left DateOrNanoseconds

The left value.

right DateOrNanoseconds

The right value.

Returns

bool

true when the values differ.