Google Cloud Spanner v1 API - Struct SpannerDate (5.0.0-beta02)

public readonly struct SpannerDate : IEquatable<SpannerDate>, IComparable<SpannerDate>, IComparable

Reference documentation and code samples for the Google Cloud Spanner v1 API struct SpannerDate.

The SpannerDate type represents a logical calendar date, independent of time zone. Represents dates with values ranging from January 1, 0001 A.D through December 31, 9999 A.D. in the Gregorian calendar.

Namespace

Google.Cloud.Spanner.V1

Assembly

Google.Cloud.Spanner.V1.dll

Constructors

SpannerDate(int, int, int)

public SpannerDate(int year, int month, int day)

Initializes a new instance of the SpannerDate structure to the specified year, month, and day in the Gregorian calendar.

Parameters
NameDescription
yearint

The year (in the range 1-9999 inclusive).

monthint

The month (in the range 1-12 inclusive).

dayint

The day (1 through the number of days in month).

Properties

Day

public int Day { get; }

Gets the day of the month of the date represented by this instance.

Property Value
TypeDescription
int

MaxDate

public static SpannerDate MaxDate { get; }

Gets the latest possible date that can be represented by SpannerDate.

Property Value
TypeDescription
SpannerDate

MinDate

public static SpannerDate MinDate { get; }

Gets the earliest possible date that can be represented by SpannerDate.

Property Value
TypeDescription
SpannerDate

Month

public int Month { get; }

Gets the month component of the date represented by this instance.

Property Value
TypeDescription
int

Year

public int Year { get; }

Gets the year component of the date represented by this instance.

Property Value
TypeDescription
int

Methods

AddDays(int)

public SpannerDate AddDays(int days)

Returns a new instance of the SpannerDate that adds the specified number of days to the value of this instance.

Parameter
NameDescription
daysint

The number of days to be added.

Returns
TypeDescription
SpannerDate

A new instance of the SpannerDate value that is the sum of the date represented by this instance and the number of days represented by days.

CompareTo(SpannerDate)

public int CompareTo(SpannerDate other)
Parameter
NameDescription
otherSpannerDate
Returns
TypeDescription
int

FromDateTime(DateTime)

public static SpannerDate FromDateTime(DateTime dateTime)

Returns a SpannerDate instance that is set to the date part of the specified DateTime.

Parameter
NameDescription
dateTimeDateTime

The DateTime value.

Returns
TypeDescription
SpannerDate

The SpannerDate instance

GetHashCode()

public override int GetHashCode()
Returns
TypeDescription
int
Overrides

Parse(string)

public static SpannerDate Parse(string text)

Parses a textual representation in yyyy-MM-dd format as a SpannerDate.

Parameter
NameDescription
textstring

The text to parse. Must not be null. Must be in yyyy-MM-dd format only.

Returns
TypeDescription
SpannerDate

The parsed value.

Remarks

text must be a representation of a date value in yyyy-MM-dd format which can be represented by SpannerDate.

Exceptions
TypeDescription
FormatException

The value could not be parsed as a SpannerDate.

ToDateTime()

public DateTime ToDateTime()

Converts the value of this SpannerDate instance to the DateTime of kind Unspecified.

Returns
TypeDescription
DateTime

The DateTime value.

ToString()

public override string ToString()

Returns the ISO 8601 representation (yyyy-MM-dd) of the date represented by this instance.

Returns
TypeDescription
string

The ISO 8601 string representation of the date represented by this instance.

Overrides

TryParse(string, out SpannerDate)

public static bool TryParse(string text, out SpannerDate value)

Attempts to parse a textual representation of date in yyyy-MM-dd format as SpannerDate.

Parameters
NameDescription
textstring

The text to parse. Must not be null. Must be in yyyy-MM-dd format only.

valueSpannerDate

The parsed value, or 0 on failure.

Returns
TypeDescription
bool

true if text was parsed successfully; false otherwise.

Remarks

See Parse(string) for format details. This method will return true if and only if Parse(string) would return without an exception.

Operators

operator ==(SpannerDate, SpannerDate)

public static bool operator ==(SpannerDate lhs, SpannerDate rhs)

Returns a value that indicates whether the values of two SpannerDate objects are equal.

Parameters
NameDescription
lhsSpannerDate

The first value to compare.

rhsSpannerDate

The second value to compare.

Returns
TypeDescription
bool

true if the two arguments are equal; false otherwise.

explicit operator DateTime(SpannerDate)

public static explicit operator DateTime(SpannerDate value)

Performs an explicit conversion from SpannerDate to DateTime.

Parameter
NameDescription
valueSpannerDate

The SpannerDate value.

Returns
TypeDescription
DateTime

The result of the conversion.

explicit operator SpannerDate(DateTime)

public static explicit operator SpannerDate(DateTime value)

Performs an explicit conversion from DateTime to SpannerDate.

Parameter
NameDescription
valueDateTime

The DateTime value.

Returns
TypeDescription
SpannerDate

The result of the conversion.

operator >(SpannerDate, SpannerDate)

public static bool operator >(SpannerDate lhs, SpannerDate rhs)

Returns a value that indicates whether a SpannerDate value is greater than another SpannerDate.

Parameters
NameDescription
lhsSpannerDate

The value to compare with rhs.

rhsSpannerDate

The value to compare with lhs.

Returns
TypeDescription
bool

true if lhs is greater than rhs; otherwise, false.

operator >=(SpannerDate, SpannerDate)

public static bool operator >=(SpannerDate lhs, SpannerDate rhs)

Returns a value that indicates whether a SpannerDate value is greater than or equal to another SpannerDate.

Parameters
NameDescription
lhsSpannerDate

The value to compare with rhs.

rhsSpannerDate

The value to compare with lhs.

Returns
TypeDescription
bool

true if lhs is greater than or equal to rhs; otherwise, false.

operator !=(SpannerDate, SpannerDate)

public static bool operator !=(SpannerDate lhs, SpannerDate rhs)

Returns a value that indicates whether the two SpannerDate objects have unequal values.

Parameters
NameDescription
lhsSpannerDate

The first value to compare.

rhsSpannerDate

The second value to compare.

Returns
TypeDescription
bool

false if the two arguments are equal; true otherwise.

operator <(SpannerDate, SpannerDate)

public static bool operator <(SpannerDate lhs, SpannerDate rhs)

Returns a value that indicates whether a SpannerDate value is less than another SpannerDate.

Parameters
NameDescription
lhsSpannerDate

The value to compare with rhs.

rhsSpannerDate

The value to compare with lhs.

Returns
TypeDescription
bool

true if lhs is less than rhs; otherwise, false.

operator <=(SpannerDate, SpannerDate)

public static bool operator <=(SpannerDate lhs, SpannerDate rhs)

Returns a value that indicates whether a SpannerDate value is less than or equal to another SpannerDate.

Parameters
NameDescription
lhsSpannerDate

The value to compare with rhs.

rhsSpannerDate

The value to compare with lhs.

Returns
TypeDescription
bool

true if lhs is less than or equal to rhs; otherwise, false.