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
GoogleGoogle.CloudGoogle.Cloud.SpannerV1Assembly
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 |
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 |
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 |
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. |
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. |
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 |
|
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 |
|
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 | SpannerDate The value to compare with |
Returns | |
---|---|
Type | Description |
bool |
|
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 | SpannerDate The value to compare with |
Returns | |
---|---|
Type | Description |
bool |
|
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 |
|
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 | SpannerDate The value to compare with |
Returns | |
---|---|
Type | Description |
bool |
|
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 | SpannerDate The value to compare with |
Returns | |
---|---|
Type | Description |
bool |
|
Explicit Interface Implementations
IComparable.CompareTo(object)
int IComparable.CompareTo(object obj)
Implementation of CompareTo(Object) to compare two SpannerDate values.
Parameter | |
---|---|
Name | Description |
obj | object The object to compare this value with. |
Returns | |
---|---|
Type | Description |
int | The result of comparing this value with |
This uses explicit interface implementation to avoid it being called accidentally. The generic implementation should usually be preferred.
Exceptions | |
---|---|
Type | Description |
ArgumentException |
|