Show / Hide Table of Contents

Struct Date

A date without a time component.

Implements
System.IEquatable<Date>
System.IComparable<Date>
System.Xml.Serialization.IXmlSerializable
Inherited Members
System.Object.Equals(System.Object, System.Object)
System.Object.GetType()
System.Object.ReferenceEquals(System.Object, System.Object)
Namespace: EC.ProductsAndPricing.ServiceContract
Assembly: EC.ProductsAndPricing.ServiceContract.dll
Syntax
public struct Date : IEquatable<Date>, IComparable<Date>, IXmlSerializable

Constructors

View Source

Date(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.

View Source

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 day, month and year aren't a valid date

Properties

View Source

Day

The day of the month

Declaration
public int Day { get; }
Property Type: System.Int32
View Source

Month

The month of the year (1 = Jan, 12 = Dec)

Declaration
public int Month { get; }
Property Type: System.Int32
View Source

Year

The year

Declaration
public int Year { get; }
Property Type: System.Int32

Methods

View Source

CompareTo(Date)

Declaration
public int CompareTo(Date other)
Parameters
Type Name Description
Date other
Returns
Type Description
System.Int32
Implements
System.IComparable<T>.CompareTo(T)
View Source

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

true if other represents the same date as this

Implements
System.IEquatable<T>.Equals(T)
View Source

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

true if obj is a Date which has the same value

Overrides
System.ValueType.Equals(System.Object)
View Source

GetHashCode()

Declaration
public override int GetHashCode()
Returns
Type Description
System.Int32
Overrides
System.ValueType.GetHashCode()
View Source

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.

View Source

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
System.ValueType.ToString()
View Source

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

true if str can be converted into a Date.

Operators

View Source

Equality(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
View Source

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
View Source

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
View Source

Implicit(Date to DateTime)

Declaration
public static implicit operator DateTime(Date date)
Parameters
Type Name Description
Date date
Returns
Type Description
System.DateTime
View Source

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

View Source

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
View Source

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
View Source

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 Source

IXmlSerializable.GetSchema()

Declaration
XmlSchema IXmlSerializable.GetSchema()
Returns
Type Description
System.Xml.Schema.XmlSchema
Implements
System.Xml.Serialization.IXmlSerializable.GetSchema()
View Source

IXmlSerializable.ReadXml(XmlReader)

Declaration
void IXmlSerializable.ReadXml(XmlReader reader)
Parameters
Type Name Description
System.Xml.XmlReader reader
Implements
System.Xml.Serialization.IXmlSerializable.ReadXml(System.Xml.XmlReader)
View Source

IXmlSerializable.WriteXml(XmlWriter)

Declaration
void IXmlSerializable.WriteXml(XmlWriter writer)
Parameters
Type Name Description
System.Xml.XmlWriter writer
Implements
System.Xml.Serialization.IXmlSerializable.WriteXml(System.Xml.XmlWriter)
  • View Source
Back to top Copyright © 2017 EC English