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

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
Name Description
year int

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

month int

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

day int

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
Type Description
int

MaxDate

public static SpannerDate MaxDate { get; }

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

Property Value
Type Description
SpannerDate

MinDate

public static SpannerDate MinDate { get; }

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

Property Value
Type Description
SpannerDate

Month

public int Month { get; }

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

Property Value
Type Description
int

Year

public int Year { get; }

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

Property Value
Type Description
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
Name Description
days int

The number of days to be added.

Returns
Type Description
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
Name Description
other SpannerDate
Returns
Type Description
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
Name Description
dateTime DateTime

The DateTime value.

Returns
Type Description
SpannerDate

The SpannerDate instance

GetHashCode()

public override int GetHashCode()
Returns
Type Description
int
Overrides

Parse(string)

public static SpannerDate Parse(string text)

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

Parameter
Name Description
text string

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

Returns
Type Description
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
Type Description
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
Type Description
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
Type Description
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
Name Description
text string

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

value SpannerDate

The parsed value, or 0 on failure.

Returns
Type Description
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
Name Description
lhs SpannerDate

The first value to compare.

rhs SpannerDate

The second value to compare.

Returns
Type Description
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
Name Description
value SpannerDate

The SpannerDate value.

Returns
Type Description
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
Name Description
value DateTime

The DateTime value.

Returns
Type Description
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
Name Description
lhs SpannerDate

The value to compare with rhs.

rhs SpannerDate

The value to compare with lhs.

Returns
Type Description
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
Name Description
lhs SpannerDate

The value to compare with rhs.

rhs SpannerDate

The value to compare with lhs.

Returns
Type Description
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
Name Description
lhs SpannerDate

The first value to compare.

rhs SpannerDate

The second value to compare.

Returns
Type Description
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
Name Description
lhs SpannerDate

The value to compare with rhs.

rhs SpannerDate

The value to compare with lhs.

Returns
Type Description
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
Name Description
lhs SpannerDate

The value to compare with rhs.

rhs SpannerDate

The value to compare with lhs.

Returns
Type Description
bool

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