Table of Contents

Struct DateOrTimestamp

Namespace
MassiveDotNet
Assembly
MassiveDotNet.dll

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

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

Remarks

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

Methods

Equals(DateOrTimestamp)

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

public bool Equals(DateOrTimestamp other)

Parameters

other DateOrTimestamp

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 DateOrTimestamp FromDate(LocalDate value)

Parameters

value LocalDate

The calendar date.

Returns

DateOrTimestamp

The wrapped value.

FromInstant(Instant)

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

public static DateOrTimestamp FromInstant(Instant value)

Parameters

value Instant

The instant.

Returns

DateOrTimestamp

The wrapped value.

FromLiteral(string)

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

public static DateOrTimestamp FromLiteral(string value)

Parameters

value string

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

Returns

DateOrTimestamp

The wrapped value.

Exceptions

ArgumentException

value is null or whitespace.

FromUnixMilliseconds(long)

Creates a value from a Unix millisecond timestamp.

public static DateOrTimestamp FromUnixMilliseconds(long epochMilliseconds)

Parameters

epochMilliseconds long

Milliseconds since the Unix epoch.

Returns

DateOrTimestamp

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 millisecond timestamp.

Operators

operator ==(DateOrTimestamp, DateOrTimestamp)

Compares two values for equality.

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

Parameters

left DateOrTimestamp

The left value.

right DateOrTimestamp

The right value.

Returns

bool

true when the values are equal.

implicit operator DateOrTimestamp(Instant)

Converts an instant.

public static implicit operator DateOrTimestamp(Instant value)

Parameters

value Instant

The instant.

Returns

DateOrTimestamp

implicit operator DateOrTimestamp(LocalDate)

Converts a calendar date.

public static implicit operator DateOrTimestamp(LocalDate value)

Parameters

value LocalDate

The calendar date.

Returns

DateOrTimestamp

implicit operator DateOrTimestamp(long)

Converts a Unix millisecond timestamp.

public static implicit operator DateOrTimestamp(long value)

Parameters

value long

Milliseconds since the Unix epoch.

Returns

DateOrTimestamp

implicit operator DateOrTimestamp(string)

Converts a literal value.

public static implicit operator DateOrTimestamp(string value)

Parameters

value string

The literal value.

Returns

DateOrTimestamp

operator !=(DateOrTimestamp, DateOrTimestamp)

Compares two values for inequality.

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

Parameters

left DateOrTimestamp

The left value.

right DateOrTimestamp

The right value.

Returns

bool

true when the values differ.