CSLA.NET 6.0.0
CSLA .NET is a software development framework that helps you build a reusable, maintainable object-oriented business layer for your app.
Csla.SmartDate Struct Reference

Provides a date data type that understands the concept of an empty date value. More...

Inheritance diagram for Csla.SmartDate:
Csla.Core.ISmartField Csla.Serialization.Mobile.IMobileObject

Public Types

enum  EmptyValue { MinDate , MaxDate }
 Indicates the empty value of a SmartDate. More...
 

Public Member Functions

 SmartDate (bool emptyIsMin)
 Creates a new SmartDate object. More...
 
 SmartDate (EmptyValue emptyValue)
 Creates a new SmartDate object. More...
 
 SmartDate (DateTime value)
 Creates a new SmartDate object. More...
 
 SmartDate (DateTime value, bool emptyIsMin)
 Creates a new SmartDate object. More...
 
 SmartDate (DateTime value, EmptyValue emptyValue)
 Creates a new SmartDate object. More...
 
 SmartDate (DateTime value, EmptyValue emptyValue, DateTimeKind kind)
 Creates a new SmartDate object. More...
 
 SmartDate (DateTime? value)
 Creates a new SmartDate object. More...
 
 SmartDate (DateTime? value, bool emptyIsMin)
 Creates a new SmartDate object. More...
 
 SmartDate (DateTime? value, EmptyValue emptyValue)
 Creates a new SmartDate object. More...
 
 SmartDate (DateTimeOffset value)
 Creates a new SmartDate object. More...
 
 SmartDate (DateTimeOffset value, bool emptyIsMin)
 Creates a new SmartDate object. More...
 
 SmartDate (DateTimeOffset value, EmptyValue emptyValue)
 Creates a new SmartDate object. More...
 
 SmartDate (string value)
 Creates a new SmartDate object. More...
 
 SmartDate (string value, bool emptyIsMin)
 Creates a new SmartDate object. More...
 
 SmartDate (string value, EmptyValue emptyValue)
 Creates a new SmartDate object. More...
 
DateTimeOffset ToDateTimeOffset ()
 Gets the value as a DateTimeOffset. More...
 
DateTime? ToNullableDate ()
 Gets the value as a DateTime?. More...
 
override string ToString ()
 Returns a text representation of the date value. More...
 
string ToString (string format)
 Returns a text representation of the date value. More...
 
override bool Equals (object obj)
 Compares this object to another SmartDate for equality. More...
 
override int GetHashCode ()
 Returns a hash code for this object. More...
 
int CompareTo (SmartDate value)
 Compares one SmartDate to another. More...
 
int IComparable. CompareTo (object value)
 Compares one SmartDate to another. More...
 
int CompareTo (string value)
 Compares a SmartDate to a text date value. More...
 
int CompareTo (DateTimeOffset value)
 Compares a SmartDate to a date value. More...
 
int CompareTo (DateTime value)
 Compares a SmartDate to a date value. More...
 
DateTime Add (TimeSpan value)
 Adds a TimeSpan onto the object. More...
 
DateTime Subtract (TimeSpan value)
 Subtracts a TimeSpan from the object. More...
 
TimeSpan Subtract (DateTimeOffset value)
 Subtracts a DateTimeOffset from the object. More...
 
TimeSpan Subtract (DateTime value)
 Subtracts a DateTime from the object. More...
 
System.TypeCode IConvertible. GetTypeCode ()
 
bool IConvertible. ToBoolean (System.IFormatProvider provider)
 
byte IConvertible. ToByte (System.IFormatProvider provider)
 
char IConvertible. ToChar (System.IFormatProvider provider)
 
System.DateTime IConvertible. ToDateTime (System.IFormatProvider provider)
 
decimal IConvertible. ToDecimal (System.IFormatProvider provider)
 
double IConvertible. ToDouble (System.IFormatProvider provider)
 
short IConvertible. ToInt16 (System.IFormatProvider provider)
 
int IConvertible. ToInt32 (System.IFormatProvider provider)
 
long IConvertible. ToInt64 (System.IFormatProvider provider)
 
sbyte IConvertible. ToSByte (System.IFormatProvider provider)
 
float IConvertible. ToSingle (System.IFormatProvider provider)
 
string IConvertible. ToString (System.IFormatProvider provider)
 
object IConvertible. ToType (System.Type conversionType, System.IFormatProvider provider)
 
ushort IConvertible. ToUInt16 (System.IFormatProvider provider)
 
uint IConvertible. ToUInt32 (System.IFormatProvider provider)
 
ulong IConvertible. ToUInt64 (System.IFormatProvider provider)
 
string IFormattable. ToString (string format, IFormatProvider formatProvider)
 
void IMobileObject. GetState (SerializationInfo info)
 Method called by MobileFormatter when an object should serialize its data. More...
 
void IMobileObject. SetState (SerializationInfo info)
 Method called by MobileFormatter when an object should be deserialized. More...
 
void IMobileObject. SetChildren (SerializationInfo info, MobileFormatter formatter)
 Method called by MobileFormatter when an object should deserialize its child references. More...
 
void IMobileObject. GetChildren (SerializationInfo info, MobileFormatter formatter)
 Method called by MobileFormatter when an object should serialize its child references. More...
 

Static Public Member Functions

static SmartDate ()
 
static void SetDefaultFormatString (string formatString)
 Sets the global default format string used by all new SmartDate values going forward. More...
 
static SmartDate Parse (string value)
 Converts a string value into a SmartDate. More...
 
static SmartDate Parse (string value, EmptyValue emptyValue)
 Converts a string value into a SmartDate. More...
 
static SmartDate Parse (string value, bool emptyIsMin)
 Converts a string value into a SmartDate. More...
 
static bool TryParse (string value, ref SmartDate result)
 Converts a string value into a SmartDate. More...
 
static bool TryParse (string value, EmptyValue emptyValue, ref SmartDate result)
 Converts a string value into a SmartDate. More...
 
static DateTime StringToDate (string value)
 Converts a text date representation into a Date value. More...
 
static DateTime StringToDate (string value, bool emptyIsMin)
 
static DateTime StringToDate (string value, EmptyValue emptyValue)
 Converts a text date representation into a Date value. More...
 
static string DateToString (DateTime value, string formatString)
 Converts a date value into a text representation. More...
 
static string DateToString (DateTime value, string formatString, bool emptyIsMin)
 Converts a date value into a text representation. More...
 
static string DateToString (DateTime value, string formatString, EmptyValue emptyValue)
 Converts a date value into a text representation. More...
 
static bool operator== (SmartDate obj1, SmartDate obj2)
 Equality operator More...
 
static bool operator!= (SmartDate obj1, SmartDate obj2)
 Inequality operator More...
 
static implicit operator string (SmartDate obj1)
 Convert a SmartDate to a String. More...
 
static implicit operator System.DateTime (SmartDate obj1)
 Convert a SmartDate to a DateTime. More...
 
static implicit operator System.DateTime? (SmartDate obj1)
 Convert a SmartDate to a nullable DateTime. More...
 
static implicit operator DateTimeOffset (SmartDate obj1)
 Convert a SmartDate to a DateTimeOffset. More...
 
static operator SmartDate (string dateValue)
 Convert a value to a SmartDate. More...
 
static implicit operator SmartDate (System.DateTime dateValue)
 Convert a value to a SmartDate. More...
 
static implicit operator SmartDate (System.DateTime? dateValue)
 Convert a value to a SmartDate. More...
 
static operator SmartDate (DateTimeOffset dateValue)
 Convert a value to a SmartDate. More...
 
static bool operator== (SmartDate obj1, DateTime obj2)
 Equality operator More...
 
static bool operator!= (SmartDate obj1, DateTime obj2)
 Inequality operator More...
 
static bool operator== (SmartDate obj1, string obj2)
 Equality operator More...
 
static bool operator!= (SmartDate obj1, string obj2)
 Inequality operator More...
 
static SmartDate operator+ (SmartDate start, TimeSpan span)
 Addition operator More...
 
static SmartDate operator- (SmartDate start, TimeSpan span)
 Subtraction operator More...
 
static TimeSpan operator- (SmartDate start, SmartDate finish)
 Subtraction operator More...
 
static bool operator> (SmartDate obj1, SmartDate obj2)
 Greater than operator More...
 
static bool operator< (SmartDate obj1, SmartDate obj2)
 Less than operator More...
 
static bool operator> (SmartDate obj1, DateTime obj2)
 Greater than operator More...
 
static bool operator< (SmartDate obj1, DateTime obj2)
 Less than operator More...
 
static bool operator> (SmartDate obj1, string obj2)
 Greater than operator More...
 
static bool operator< (SmartDate obj1, string obj2)
 Less than operator More...
 
static bool operator>= (SmartDate obj1, SmartDate obj2)
 Greater than or equals operator More...
 
static bool operator<= (SmartDate obj1, SmartDate obj2)
 Less than or equals operator More...
 
static bool operator>= (SmartDate obj1, DateTime obj2)
 Greater than or equals operator More...
 
static bool operator<= (SmartDate obj1, DateTime obj2)
 Less than or equals operator More...
 
static bool operator>= (SmartDate obj1, string obj2)
 Greater than or equals operator More...
 
static bool operator<= (SmartDate obj1, string obj2)
 Less than or equals operator More...
 

Properties

string FormatString [getset]
 Gets or sets the format string used to format a date value when it is returned as text. More...
 
string Text [getset]
 Gets or sets the date value. More...
 
DateTime? Date [getset]
 Gets or sets the date value. More...
 
object DBValue [get]
 Gets a database-friendly version of the date value. More...
 
bool IsEmpty [get]
 Gets a value indicating whether this object contains an empty date. More...
 
bool EmptyIsMin [get]
 Gets a value indicating whether an empty date is the min or max possible date value. More...
 
static Func< string, DateTime?> CustomParser [getset]
 Gets or sets the custom parser. More...
 
- Properties inherited from Csla.Core.ISmartField
string Text [getset]
 Sets or gets the text representation of the value. More...
 
bool IsEmpty [get]
 Gets a value indicating whether the field's value is empty. More...
 

Detailed Description

Provides a date data type that understands the concept of an empty date value.

See Chapter 5 for a full discussion of the need for this data type and the design choices behind it.

Definition at line 27 of file SmartDate.cs.

Member Enumeration Documentation

◆ EmptyValue

Indicates the empty value of a SmartDate.

Enumerator
MinDate 

Indicates that an empty SmartDate is the smallest date.

MaxDate 

Indicates that an empty SmartDate is the largest date.

Definition at line 51 of file SmartDate.cs.

Constructor & Destructor Documentation

◆ SmartDate() [1/16]

static Csla.SmartDate.SmartDate ( )
static

Definition at line 69 of file SmartDate.cs.

◆ SmartDate() [2/16]

Csla.SmartDate.SmartDate ( bool  emptyIsMin)

Creates a new SmartDate object.

Parameters
emptyIsMinIndicates whether an empty date is the min or max date value.

Definition at line 78 of file SmartDate.cs.

◆ SmartDate() [3/16]

Csla.SmartDate.SmartDate ( EmptyValue  emptyValue)

Creates a new SmartDate object.

Parameters
emptyValueIndicates whether an empty date is the min or max date value.

Definition at line 92 of file SmartDate.cs.

◆ SmartDate() [4/16]

Csla.SmartDate.SmartDate ( DateTime  value)

Creates a new SmartDate object.

The SmartDate created will use the min possible date to represent an empty date.

Parameters
valueThe initial value of the object.

Definition at line 110 of file SmartDate.cs.

◆ SmartDate() [5/16]

Csla.SmartDate.SmartDate ( DateTime  value,
bool  emptyIsMin 
)

Creates a new SmartDate object.

Parameters
valueThe initial value of the object.
emptyIsMinIndicates whether an empty date is the min or max date value.

Definition at line 124 of file SmartDate.cs.

◆ SmartDate() [6/16]

Csla.SmartDate.SmartDate ( DateTime  value,
EmptyValue  emptyValue 
)

Creates a new SmartDate object.

Parameters
valueThe initial value of the object.
emptyValueIndicates whether an empty date is the min or max date value.

Definition at line 138 of file SmartDate.cs.

◆ SmartDate() [7/16]

Csla.SmartDate.SmartDate ( DateTime  value,
EmptyValue  emptyValue,
DateTimeKind  kind 
)

Creates a new SmartDate object.

Parameters
valueThe initial value of the object.
emptyValueIndicates whether an empty date is the min or max date value.
kindOne of the DateTimeKind values.

Definition at line 153 of file SmartDate.cs.

◆ SmartDate() [8/16]

Csla.SmartDate.SmartDate ( DateTime?  value)

Creates a new SmartDate object.

The SmartDate created will use the min possible date to represent an empty date.

Parameters
valueThe initial value of the object.

Definition at line 170 of file SmartDate.cs.

◆ SmartDate() [9/16]

Csla.SmartDate.SmartDate ( DateTime?  value,
bool  emptyIsMin 
)

Creates a new SmartDate object.

Parameters
valueThe initial value of the object.
emptyIsMinIndicates whether an empty date is the min or max date value.

Definition at line 185 of file SmartDate.cs.

◆ SmartDate() [10/16]

Csla.SmartDate.SmartDate ( DateTime?  value,
EmptyValue  emptyValue 
)

Creates a new SmartDate object.

Parameters
valueThe initial value of the object.
emptyValueIndicates whether an empty date is the min or max date value.

Definition at line 200 of file SmartDate.cs.

◆ SmartDate() [11/16]

Csla.SmartDate.SmartDate ( DateTimeOffset  value)

Creates a new SmartDate object.

The SmartDate created will use the min possible date to represent an empty date.

SmartDate maintains the date value as a DateTime, so the provided DateTimeOffset is converted to a DateTime in this constructor. You should be aware that this can lead to a loss of precision in some cases.

Parameters
valueThe initial value of the object.

Definition at line 226 of file SmartDate.cs.

◆ SmartDate() [12/16]

Csla.SmartDate.SmartDate ( DateTimeOffset  value,
bool  emptyIsMin 
)

Creates a new SmartDate object.

Parameters
valueThe initial value of the object.
emptyIsMinIndicates whether an empty date is the min or max date value.

SmartDate maintains the date value as a DateTime, so the provided DateTimeOffset is converted to a DateTime in this constructor. You should be aware that this can lead to a loss of precision in some cases.

Definition at line 247 of file SmartDate.cs.

◆ SmartDate() [13/16]

Csla.SmartDate.SmartDate ( DateTimeOffset  value,
EmptyValue  emptyValue 
)

Creates a new SmartDate object.

Parameters
valueThe initial value of the object.
emptyValueIndicates whether an empty date is the min or max date value.

SmartDate maintains the date value as a DateTime, so the provided DateTimeOffset is converted to a DateTime in this constructor. You should be aware that this can lead to a loss of precision in some cases.

Definition at line 268 of file SmartDate.cs.

◆ SmartDate() [14/16]

Csla.SmartDate.SmartDate ( string  value)

Creates a new SmartDate object.

The SmartDate created will use the min possible date to represent an empty date.

Parameters
valueThe initial value of the object (as text).

Definition at line 285 of file SmartDate.cs.

◆ SmartDate() [15/16]

Csla.SmartDate.SmartDate ( string  value,
bool  emptyIsMin 
)

Creates a new SmartDate object.

Parameters
valueThe initial value of the object (as text).
emptyIsMinIndicates whether an empty date is the min or max date value.

Definition at line 299 of file SmartDate.cs.

◆ SmartDate() [16/16]

Csla.SmartDate.SmartDate ( string  value,
EmptyValue  emptyValue 
)

Creates a new SmartDate object.

Parameters
valueThe initial value of the object (as text).
emptyValueIndicates whether an empty date is the min or max date value.

Definition at line 313 of file SmartDate.cs.

Member Function Documentation

◆ Add()

DateTime Csla.SmartDate.Add ( TimeSpan  value)

Adds a TimeSpan onto the object.

Parameters
valueSpan to add to the date.

Definition at line 910 of file SmartDate.cs.

◆ CompareTo() [1/5]

int Csla.SmartDate.CompareTo ( DateTime  value)

Compares a SmartDate to a date value.

Parameters
valueThe date to which we are being compared.
Returns
A value indicating if the comparison date is less than, equal to or greater than this date.

Definition at line 901 of file SmartDate.cs.

◆ CompareTo() [2/5]

int Csla.SmartDate.CompareTo ( DateTimeOffset  value)

Compares a SmartDate to a date value.

Parameters
valueThe date to which we are being compared.
Returns
A value indicating if the comparison date is less than, equal to or greater than this date.

SmartDate maintains the date value as a DateTime, so the provided DateTimeOffset is converted to a DateTime for this comparison. You should be aware that this can lead to a loss of precision in some cases.

Definition at line 891 of file SmartDate.cs.

◆ CompareTo() [3/5]

int IComparable. Csla.SmartDate.CompareTo ( object  value)

Compares one SmartDate to another.

This method works the same as the DateTime.CompareTo method on the Date datetype, with the exception that it understands the concept of empty date values.

Parameters
valueThe date to which we are being compared.
Returns
A value indicating if the comparison date is less than, equal to or greater than this date.

Definition at line 861 of file SmartDate.cs.

◆ CompareTo() [4/5]

int Csla.SmartDate.CompareTo ( SmartDate  value)

Compares one SmartDate to another.

This method works the same as the DateTime.CompareTo method on the Date datetype, with the exception that it understands the concept of empty date values.

Parameters
valueThe date to which we are being compared.
Returns
A value indicating if the comparison date is less than, equal to or greater than this date.

Definition at line 843 of file SmartDate.cs.

◆ CompareTo() [5/5]

int Csla.SmartDate.CompareTo ( string  value)

Compares a SmartDate to a text date value.

Parameters
valueThe date to which we are being compared.
Returns
A value indicating if the comparison date is less than, equal to or greater than this date.

Definition at line 874 of file SmartDate.cs.

◆ DateToString() [1/3]

static string Csla.SmartDate.DateToString ( DateTime  value,
string  formatString 
)
static

Converts a date value into a text representation.

The date is considered empty if it matches the min value for the Date datatype. If the date is empty, this method returns an empty string. Otherwise it returns the date value formatted based on the FormatString parameter.

Parameters
valueThe date value to convert.
formatStringThe format string used to format the date into text.
Returns
Text representation of the date value.

Definition at line 775 of file SmartDate.cs.

◆ DateToString() [2/3]

static string Csla.SmartDate.DateToString ( DateTime  value,
string  formatString,
bool  emptyIsMin 
)
static

Converts a date value into a text representation.

Whether the date value is considered empty is determined by the EmptyIsMin parameter value. If the date is empty, this method returns an empty string. Otherwise it returns the date value formatted based on the FormatString parameter.

Parameters
valueThe date value to convert.
formatStringThe format string used to format the date into text.
emptyIsMinIndicates whether an empty date is the min or max date value.
Returns
Text representation of the date value.

Definition at line 794 of file SmartDate.cs.

◆ DateToString() [3/3]

static string Csla.SmartDate.DateToString ( DateTime  value,
string  formatString,
EmptyValue  emptyValue 
)
static

Converts a date value into a text representation.

Whether the date value is considered empty is determined by the EmptyIsMin parameter value. If the date is empty, this method returns an empty string. Otherwise it returns the date value formatted based on the FormatString parameter.

Parameters
valueThe date value to convert.
formatStringThe format string used to format the date into text.
emptyValueIndicates whether an empty date is the min or max date value.
Returns
Text representation of the date value.

Definition at line 813 of file SmartDate.cs.

◆ Equals()

override bool Csla.SmartDate.Equals ( object  obj)

Compares this object to another SmartDate for equality.

Parameters
objObject to compare for equality.

Definition at line 480 of file SmartDate.cs.

◆ GetChildren()

void IMobileObject. Csla.SmartDate.GetChildren ( SerializationInfo  info,
MobileFormatter  formatter 
)

Method called by MobileFormatter when an object should serialize its child references.

The data should be serialized into the SerializationInfo parameter.

Parameters
infoObject to contain the serialized data.
formatterReference to the formatter performing the serialization.

Implements Csla.Serialization.Mobile.IMobileObject.

Definition at line 1401 of file SmartDate.cs.

◆ GetHashCode()

override int Csla.SmartDate.GetHashCode ( )

Returns a hash code for this object.

Definition at line 501 of file SmartDate.cs.

◆ GetState()

void IMobileObject. Csla.SmartDate.GetState ( SerializationInfo  info)

Method called by MobileFormatter when an object should serialize its data.

The data should be serialized into the SerializationInfo parameter.

Parameters
infoObject to contain the serialized data.

Implements Csla.Serialization.Mobile.IMobileObject.

Definition at line 1378 of file SmartDate.cs.

◆ GetTypeCode()

System.TypeCode IConvertible. Csla.SmartDate.GetTypeCode ( )

Definition at line 1273 of file SmartDate.cs.

◆ operator DateTimeOffset()

static implicit Csla.SmartDate.operator DateTimeOffset ( SmartDate  obj1)
static

Convert a SmartDate to a DateTimeOffset.

Parameters
obj1SmartDate value.

Definition at line 1018 of file SmartDate.cs.

◆ operator SmartDate() [1/4]

static Csla.SmartDate.operator SmartDate ( DateTimeOffset  dateValue)
explicitstatic

Convert a value to a SmartDate.

Parameters
dateValueValue to convert.

Definition at line 1054 of file SmartDate.cs.

◆ operator SmartDate() [2/4]

static Csla.SmartDate.operator SmartDate ( string  dateValue)
explicitstatic

Convert a value to a SmartDate.

Parameters
dateValueValue to convert.

Definition at line 1027 of file SmartDate.cs.

◆ operator SmartDate() [3/4]

static implicit Csla.SmartDate.operator SmartDate ( System.DateTime  dateValue)
static

Convert a value to a SmartDate.

Parameters
dateValueValue to convert.

Definition at line 1036 of file SmartDate.cs.

◆ operator SmartDate() [4/4]

static implicit Csla.SmartDate.operator SmartDate ( System.DateTime?  dateValue)
static

Convert a value to a SmartDate.

Parameters
dateValueValue to convert.

Definition at line 1045 of file SmartDate.cs.

◆ operator string()

static implicit Csla.SmartDate.operator string ( SmartDate  obj1)
static

Convert a SmartDate to a String.

Parameters
obj1SmartDate value.

Definition at line 991 of file SmartDate.cs.

◆ operator System.DateTime()

static implicit Csla.SmartDate.operator System.DateTime ( SmartDate  obj1)
static

Convert a SmartDate to a DateTime.

Parameters
obj1SmartDate value.

Definition at line 1000 of file SmartDate.cs.

◆ operator System.DateTime?()

static implicit Csla.SmartDate.operator System.DateTime? ( SmartDate  obj1)
static

Convert a SmartDate to a nullable DateTime.

Parameters
obj1SmartDate value.

Definition at line 1009 of file SmartDate.cs.

◆ operator!=() [1/3]

static bool Csla.SmartDate.operator!= ( SmartDate  obj1,
DateTime  obj2 
)
static

Inequality operator

Parameters
obj1First object
obj2Second object
Returns

Definition at line 1076 of file SmartDate.cs.

◆ operator!=() [2/3]

static bool Csla.SmartDate.operator!= ( SmartDate  obj1,
SmartDate  obj2 
)
static

Inequality operator

Parameters
obj1First object
obj2Second object
Returns

Definition at line 982 of file SmartDate.cs.

◆ operator!=() [3/3]

static bool Csla.SmartDate.operator!= ( SmartDate  obj1,
string  obj2 
)
static

Inequality operator

Parameters
obj1First object
obj2Second object
Returns

Definition at line 1098 of file SmartDate.cs.

◆ operator+()

static SmartDate Csla.SmartDate.operator+ ( SmartDate  start,
TimeSpan  span 
)
static

Addition operator

Parameters
startOriginal date/time
spanSpan to add
Returns

Definition at line 1109 of file SmartDate.cs.

◆ operator-() [1/2]

static TimeSpan Csla.SmartDate.operator- ( SmartDate  start,
SmartDate  finish 
)
static

Subtraction operator

Parameters
startOriginal date/time
finishSecond date/time
Returns

Definition at line 1131 of file SmartDate.cs.

◆ operator-() [2/2]

static SmartDate Csla.SmartDate.operator- ( SmartDate  start,
TimeSpan  span 
)
static

Subtraction operator

Parameters
startOriginal date/time
spanSpan to subtract
Returns

Definition at line 1120 of file SmartDate.cs.

◆ operator<() [1/3]

static bool Csla.SmartDate.operator< ( SmartDate  obj1,
DateTime  obj2 
)
static

Less than operator

Parameters
obj1First object
obj2Second object
Returns

Definition at line 1175 of file SmartDate.cs.

◆ operator<() [2/3]

static bool Csla.SmartDate.operator< ( SmartDate  obj1,
SmartDate  obj2 
)
static

Less than operator

Parameters
obj1First object
obj2Second object
Returns

Definition at line 1153 of file SmartDate.cs.

◆ operator<() [3/3]

static bool Csla.SmartDate.operator< ( SmartDate  obj1,
string  obj2 
)
static

Less than operator

Parameters
obj1First object
obj2Second object
Returns

Definition at line 1197 of file SmartDate.cs.

◆ operator<=() [1/3]

static bool Csla.SmartDate.operator<= ( SmartDate  obj1,
DateTime  obj2 
)
static

Less than or equals operator

Parameters
obj1First object
obj2Second object
Returns

Definition at line 1241 of file SmartDate.cs.

◆ operator<=() [2/3]

static bool Csla.SmartDate.operator<= ( SmartDate  obj1,
SmartDate  obj2 
)
static

Less than or equals operator

Parameters
obj1First object
obj2Second object
Returns

Definition at line 1219 of file SmartDate.cs.

◆ operator<=() [3/3]

static bool Csla.SmartDate.operator<= ( SmartDate  obj1,
string  obj2 
)
static

Less than or equals operator

Parameters
obj1First object
obj2Second object
Returns

Definition at line 1263 of file SmartDate.cs.

◆ operator==() [1/3]

static bool Csla.SmartDate.operator== ( SmartDate  obj1,
DateTime  obj2 
)
static

Equality operator

Parameters
obj1First object
obj2Second object
Returns

Definition at line 1065 of file SmartDate.cs.

◆ operator==() [2/3]

static bool Csla.SmartDate.operator== ( SmartDate  obj1,
SmartDate  obj2 
)
static

Equality operator

Parameters
obj1First object
obj2Second object
Returns

Definition at line 971 of file SmartDate.cs.

◆ operator==() [3/3]

static bool Csla.SmartDate.operator== ( SmartDate  obj1,
string  obj2 
)
static

Equality operator

Parameters
obj1First object
obj2Second object
Returns

Definition at line 1087 of file SmartDate.cs.

◆ operator>() [1/3]

static bool Csla.SmartDate.operator> ( SmartDate  obj1,
DateTime  obj2 
)
static

Greater than operator

Parameters
obj1First object
obj2Second object
Returns

Definition at line 1164 of file SmartDate.cs.

◆ operator>() [2/3]

static bool Csla.SmartDate.operator> ( SmartDate  obj1,
SmartDate  obj2 
)
static

Greater than operator

Parameters
obj1First object
obj2Second object
Returns

Definition at line 1142 of file SmartDate.cs.

◆ operator>() [3/3]

static bool Csla.SmartDate.operator> ( SmartDate  obj1,
string  obj2 
)
static

Greater than operator

Parameters
obj1First object
obj2Second object
Returns

Definition at line 1186 of file SmartDate.cs.

◆ operator>=() [1/3]

static bool Csla.SmartDate.operator>= ( SmartDate  obj1,
DateTime  obj2 
)
static

Greater than or equals operator

Parameters
obj1First object
obj2Second object
Returns

Definition at line 1230 of file SmartDate.cs.

◆ operator>=() [2/3]

static bool Csla.SmartDate.operator>= ( SmartDate  obj1,
SmartDate  obj2 
)
static

Greater than or equals operator

Parameters
obj1First object
obj2Second object
Returns

Definition at line 1208 of file SmartDate.cs.

◆ operator>=() [3/3]

static bool Csla.SmartDate.operator>= ( SmartDate  obj1,
string  obj2 
)
static

Greater than or equals operator

Parameters
obj1First object
obj2Second object
Returns

Definition at line 1252 of file SmartDate.cs.

◆ Parse() [1/3]

static SmartDate Csla.SmartDate.Parse ( string  value)
static

Converts a string value into a SmartDate.

Parameters
valueString containing the date value.
Returns
A new SmartDate containing the date value.

EmptyIsMin will default to true.

Definition at line 600 of file SmartDate.cs.

◆ Parse() [2/3]

static SmartDate Csla.SmartDate.Parse ( string  value,
bool  emptyIsMin 
)
static

Converts a string value into a SmartDate.

Parameters
valueString containing the date value.
emptyIsMinIndicates whether an empty date is the min or max date value.
Returns
A new SmartDate containing the date value.

Definition at line 622 of file SmartDate.cs.

◆ Parse() [3/3]

static SmartDate Csla.SmartDate.Parse ( string  value,
EmptyValue  emptyValue 
)
static

Converts a string value into a SmartDate.

Parameters
valueString containing the date value.
emptyValueIndicates whether an empty date is the min or max date value.
Returns
A new SmartDate containing the date value.

Definition at line 611 of file SmartDate.cs.

◆ SetChildren()

void IMobileObject. Csla.SmartDate.SetChildren ( SerializationInfo  info,
MobileFormatter  formatter 
)

Method called by MobileFormatter when an object should deserialize its child references.

The data should be deserialized from the SerializationInfo parameter.

Parameters
infoObject containing the serialized data.
formatterReference to the formatter performing the deserialization.

Implements Csla.Serialization.Mobile.IMobileObject.

Definition at line 1396 of file SmartDate.cs.

◆ SetDefaultFormatString()

static void Csla.SmartDate.SetDefaultFormatString ( string  formatString)
static

Sets the global default format string used by all new SmartDate values going forward.

The default global format string is "d" unless this method is called to change that value. Existing SmartDate values are unaffected by this method, only SmartDate values created after calling this method are affected.

Parameters
formatStringThe format string should follow the requirements for the .NET System.String.Format statement.

Definition at line 356 of file SmartDate.cs.

◆ SetState()

void IMobileObject. Csla.SmartDate.SetState ( SerializationInfo  info)

Method called by MobileFormatter when an object should be deserialized.

The data should be deserialized from the SerializationInfo parameter.

Parameters
infoObject containing the serialized data.

Implements Csla.Serialization.Mobile.IMobileObject.

Definition at line 1387 of file SmartDate.cs.

◆ StringToDate() [1/3]

static DateTime Csla.SmartDate.StringToDate ( string  value)
static

Converts a text date representation into a Date value.

An empty string is assumed to represent an empty date. An empty date is returned as the MinValue of the Date datatype.

Parameters
valueThe text representation of the date.
Returns
A Date value.

Definition at line 668 of file SmartDate.cs.

◆ StringToDate() [2/3]

static DateTime Csla.SmartDate.StringToDate ( string  value,
bool  emptyIsMin 
)
static

Converts a text date representation into a Date value.

An empty string is assumed to represent an empty date. An empty date is returned as the MinValue or MaxValue of the Date datatype depending on the EmptyIsMin parameter.

Parameters
valueThe text representation of the date.
emptyIsMinIndicates whether an empty date is the min or max date value.
Returns
A Date value.

Definition at line 684 of file SmartDate.cs.

◆ StringToDate() [3/3]

static DateTime Csla.SmartDate.StringToDate ( string  value,
EmptyValue  emptyValue 
)
static

Converts a text date representation into a Date value.

An empty string is assumed to represent an empty date. An empty date is returned as the MinValue or MaxValue of the Date datatype depending on the EmptyIsMin parameter.

Parameters
valueThe text representation of the date.
emptyValueIndicates whether an empty date is the min or max date value.
Returns
A Date value.

Definition at line 700 of file SmartDate.cs.

◆ Subtract() [1/3]

TimeSpan Csla.SmartDate.Subtract ( DateTime  value)

Subtracts a DateTime from the object.

Parameters
valueDate to subtract from the date.

Definition at line 953 of file SmartDate.cs.

◆ Subtract() [2/3]

TimeSpan Csla.SmartDate.Subtract ( DateTimeOffset  value)

Subtracts a DateTimeOffset from the object.

Parameters
valueDateTimeOffset to subtract from the date.

SmartDate maintains the date value as a DateTime, so the provided DateTimeOffset is converted to a DateTime for this comparison. You should be aware that this can lead to a loss of precision in some cases.

Definition at line 941 of file SmartDate.cs.

◆ Subtract() [3/3]

DateTime Csla.SmartDate.Subtract ( TimeSpan  value)

Subtracts a TimeSpan from the object.

Parameters
valueSpan to subtract from the date.

Definition at line 922 of file SmartDate.cs.

◆ ToBoolean()

bool IConvertible. Csla.SmartDate.ToBoolean ( System.IFormatProvider  provider)

Definition at line 1278 of file SmartDate.cs.

◆ ToByte()

byte IConvertible. Csla.SmartDate.ToByte ( System.IFormatProvider  provider)

Definition at line 1283 of file SmartDate.cs.

◆ ToChar()

char IConvertible. Csla.SmartDate.ToChar ( System.IFormatProvider  provider)

Definition at line 1288 of file SmartDate.cs.

◆ ToDateTime()

System.DateTime IConvertible. Csla.SmartDate.ToDateTime ( System.IFormatProvider  provider)

Definition at line 1293 of file SmartDate.cs.

◆ ToDateTimeOffset()

DateTimeOffset Csla.SmartDate.ToDateTimeOffset ( )

Gets the value as a DateTimeOffset.

Definition at line 433 of file SmartDate.cs.

◆ ToDecimal()

decimal IConvertible. Csla.SmartDate.ToDecimal ( System.IFormatProvider  provider)

Definition at line 1298 of file SmartDate.cs.

◆ ToDouble()

double IConvertible. Csla.SmartDate.ToDouble ( System.IFormatProvider  provider)

Definition at line 1303 of file SmartDate.cs.

◆ ToInt16()

short IConvertible. Csla.SmartDate.ToInt16 ( System.IFormatProvider  provider)

Definition at line 1308 of file SmartDate.cs.

◆ ToInt32()

int IConvertible. Csla.SmartDate.ToInt32 ( System.IFormatProvider  provider)

Definition at line 1313 of file SmartDate.cs.

◆ ToInt64()

long IConvertible. Csla.SmartDate.ToInt64 ( System.IFormatProvider  provider)

Definition at line 1318 of file SmartDate.cs.

◆ ToNullableDate()

DateTime? Csla.SmartDate.ToNullableDate ( )

Gets the value as a DateTime?.

Definition at line 441 of file SmartDate.cs.

◆ ToSByte()

sbyte IConvertible. Csla.SmartDate.ToSByte ( System.IFormatProvider  provider)

Definition at line 1323 of file SmartDate.cs.

◆ ToSingle()

float IConvertible. Csla.SmartDate.ToSingle ( System.IFormatProvider  provider)

Definition at line 1328 of file SmartDate.cs.

◆ ToString() [1/4]

override string Csla.SmartDate.ToString ( )

Returns a text representation of the date value.

Definition at line 456 of file SmartDate.cs.

◆ ToString() [2/4]

string Csla.SmartDate.ToString ( string  format)

Returns a text representation of the date value.

Parameters
formatA standard .NET format string.

Definition at line 467 of file SmartDate.cs.

◆ ToString() [3/4]

string IFormattable. Csla.SmartDate.ToString ( string  format,
IFormatProvider  formatProvider 
)

Definition at line 1369 of file SmartDate.cs.

◆ ToString() [4/4]

string IConvertible. Csla.SmartDate.ToString ( System.IFormatProvider  provider)

Definition at line 1333 of file SmartDate.cs.

◆ ToType()

object IConvertible. Csla.SmartDate.ToType ( System.Type  conversionType,
System.IFormatProvider  provider 
)

Definition at line 1338 of file SmartDate.cs.

◆ ToUInt16()

ushort IConvertible. Csla.SmartDate.ToUInt16 ( System.IFormatProvider  provider)

Definition at line 1348 of file SmartDate.cs.

◆ ToUInt32()

uint IConvertible. Csla.SmartDate.ToUInt32 ( System.IFormatProvider  provider)

Definition at line 1353 of file SmartDate.cs.

◆ ToUInt64()

ulong IConvertible. Csla.SmartDate.ToUInt64 ( System.IFormatProvider  provider)

Definition at line 1358 of file SmartDate.cs.

◆ TryParse() [1/2]

static bool Csla.SmartDate.TryParse ( string  value,
EmptyValue  emptyValue,
ref SmartDate  result 
)
static

Converts a string value into a SmartDate.

Parameters
valueString containing the date value.
emptyValueIndicates whether an empty date is the min or max date value.
resultThe resulting SmartDate value if the parse was successful.
Returns
A value indicating if the parse was successful.

Definition at line 645 of file SmartDate.cs.

◆ TryParse() [2/2]

static bool Csla.SmartDate.TryParse ( string  value,
ref SmartDate  result 
)
static

Converts a string value into a SmartDate.

Parameters
valueString containing the date value.
resultThe resulting SmartDate value if the parse was successful.
Returns
A value indicating if the parse was successful.

Definition at line 633 of file SmartDate.cs.

Property Documentation

◆ CustomParser

Func<string, DateTime?> Csla.SmartDate.CustomParser
staticgetset

Gets or sets the custom parser.

The CustomParser is called first in TryStringToDate to allow custom parsing. The parser method must return null if unable to parse and allow SmartDate to try default parsing.

The custom parser.

Definition at line 585 of file SmartDate.cs.

◆ Date

DateTime? Csla.SmartDate.Date
getset

Gets or sets the date value.

Definition at line 412 of file SmartDate.cs.

◆ DBValue

object Csla.SmartDate.DBValue
get

Gets a database-friendly version of the date value.

If the SmartDate contains an empty date, this returns DBNull. Otherwise the actual date value is returned as type Date.

This property is very useful when setting parameter values for a Command object, since it automatically stores null values into the database for empty date values.

When you also use the SafeDataReader and its GetSmartDate method, you can easily read a null value from the database back into a SmartDate object so it remains considered as an empty date value.

Definition at line 528 of file SmartDate.cs.

◆ EmptyIsMin

bool Csla.SmartDate.EmptyIsMin
get

Gets a value indicating whether an empty date is the min or max possible date value.

Whether an empty date is considered to be the smallest or largest possible date is only important for comparison operations. This allows you to compare an empty date with a real date and get a meaningful result.

Definition at line 567 of file SmartDate.cs.

◆ FormatString

string Csla.SmartDate.FormatString
getset

Gets or sets the format string used to format a date value when it is returned as text.

The format string should follow the requirements for the .NET System.String.Format statement.

A format string.

Definition at line 370 of file SmartDate.cs.

◆ IsEmpty

bool Csla.SmartDate.IsEmpty
get

Gets a value indicating whether this object contains an empty date.

Definition at line 547 of file SmartDate.cs.

◆ Text

string Csla.SmartDate.Text
getset

Gets or sets the date value.

This property can be used to set the date value by passing a text representation of the date. Any text date representation that can be parsed by the .NET runtime is valid.

When the date value is retrieved via this property, the text is formatted by using the format specified by the FormatString property. The default is the short date format (d).

Definition at line 399 of file SmartDate.cs.