Struct Date
A date without a time component.
Implements
Inherited Members
Namespace: EC.ProductsAndPricing.ServiceContract
Assembly: EC.ProductsAndPricing.ServiceContract.dll
Syntax
public struct Date : IEquatable<Date>, IComparable<Date>, IXmlSerializable
Constructors
View SourceDate(DateTime)
Create a date using a specific System.DateTime
Declaration
public Date(DateTime dateTime)
Parameters
Type | Name | Description |
---|---|---|
System.DateTime | dateTime | A System.DateTime from the BCL. |
Date(Int32, Int32, Int32)
Create a date using a specific day month and year
Declaration
public Date(int year, int month, int day)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | year | The year |
System.Int32 | month | The month of the year |
System.Int32 | day | The day of the month |
Exceptions
Type | Condition |
---|---|
System.ArgumentOutOfRangeException | If |
Properties
View SourceDay
The day of the month
Declaration
public int Day { get; }
Month
The month of the year (1 = Jan, 12 = Dec)
Declaration
public int Month { get; }
Year
The year
Declaration
public int Year { get; }
Methods
View SourceCompareTo(Date)
Declaration
public int CompareTo(Date other)
Parameters
Type | Name | Description |
---|---|---|
Date | other |
Returns
Type | Description |
---|---|
System.Int32 |
Implements
Equals(Date)
Compare to a date.
Declaration
public bool Equals(Date other)
Parameters
Type | Name | Description |
---|---|---|
Date | other | The date to compare to. |
Returns
Type | Description |
---|---|
System.Boolean |
|
Implements
Equals(Object)
Compare to any object
Declaration
public override bool Equals(object obj)
Parameters
Type | Name | Description |
---|---|---|
System.Object | obj | The object to compare to. |
Returns
Type | Description |
---|---|
System.Boolean |
|
Overrides
GetHashCode()
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
System.Int32 |
Overrides
Parse(String)
Parse an ISO date string
Declaration
public static Date Parse(string str)
Parameters
Type | Name | Description |
---|---|---|
System.String | str | The date in YYYY-MM-DD format |
Returns
Type | Description |
---|---|
Date | The parsed date |
Exceptions
Type | Condition |
---|---|
System.InvalidCastException | If the date cannot be parsed. |
ToString()
Prints the date as an ISO value.
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
System.String | A string representing the date in YYYY-MM-DD format. |
Overrides
TryParse(String, out Date)
Try and parse an ISO date string
Declaration
public static bool TryParse(string str, out Date date)
Parameters
Type | Name | Description |
---|---|---|
System.String | str | The date in YYYY-MM-DD format |
Date | date | The parsed date, or an empty date if the string cannot be parsed |
Returns
Type | Description |
---|---|
System.Boolean |
|
Operators
View SourceEquality(Date, Date)
Equals operator
Declaration
public static bool operator ==(Date left, Date right)
Parameters
Type | Name | Description |
---|---|---|
Date | left | |
Date | right |
Returns
Type | Description |
---|---|
System.Boolean |
GreaterThan(Date, Date)
Greater than operator
Declaration
public static bool operator>(Date left, Date right)
Parameters
Type | Name | Description |
---|---|---|
Date | left | |
Date | right |
Returns
Type | Description |
---|---|
System.Boolean |
GreaterThanOrEqual(Date, Date)
Greater than or equals
Declaration
public static bool operator >=(Date left, Date right)
Parameters
Type | Name | Description |
---|---|---|
Date | left | |
Date | right |
Returns
Type | Description |
---|---|
System.Boolean |
Implicit(Date to DateTime)
Declaration
public static implicit operator DateTime(Date date)
Parameters
Type | Name | Description |
---|---|---|
Date | date |
Returns
Type | Description |
---|---|
System.DateTime |
Implicit(DateTime to Date)
Implicitly convert a System.DateTime to a Date
Declaration
public static implicit operator Date(DateTime dateTime)
Parameters
Type | Name | Description |
---|---|---|
System.DateTime | dateTime |
Returns
Type | Description |
---|---|
Date | A new date object |
Inequality(Date, Date)
Not equals operator
Declaration
public static bool operator !=(Date left, Date right)
Parameters
Type | Name | Description |
---|---|---|
Date | left | |
Date | right |
Returns
Type | Description |
---|---|
System.Boolean |
LessThan(Date, Date)
Less than operator
Declaration
public static bool operator <(Date left, Date right)
Parameters
Type | Name | Description |
---|---|---|
Date | left | |
Date | right |
Returns
Type | Description |
---|---|
System.Boolean |
LessThanOrEqual(Date, Date)
Less than or equals
Declaration
public static bool operator <=(Date left, Date right)
Parameters
Type | Name | Description |
---|---|---|
Date | left | |
Date | right |
Returns
Type | Description |
---|---|
System.Boolean |
Explicit Interface Implementations
View SourceIXmlSerializable.GetSchema()
Declaration
XmlSchema IXmlSerializable.GetSchema()
Returns
Type | Description |
---|---|
System.Xml.Schema.XmlSchema |
Implements
IXmlSerializable.ReadXml(XmlReader)
Declaration
void IXmlSerializable.ReadXml(XmlReader reader)
Parameters
Type | Name | Description |
---|---|---|
System.Xml.XmlReader | reader |
Implements
IXmlSerializable.WriteXml(XmlWriter)
Declaration
void IXmlSerializable.WriteXml(XmlWriter writer)
Parameters
Type | Name | Description |
---|---|---|
System.Xml.XmlWriter | writer |