CSLA .NET 10.0.0
A home for your business logic
Loading...
Searching...
No Matches
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.
 SmartDate (EmptyValue emptyValue)
 Creates a new SmartDate object.
 SmartDate (DateTime value)
 Creates a new SmartDate object.
 SmartDate (DateTime value, bool emptyIsMin)
 Creates a new SmartDate object.
 SmartDate (DateTime value, EmptyValue emptyValue)
 Creates a new SmartDate object.
 SmartDate (DateTime value, EmptyValue emptyValue, DateTimeKind kind)
 Creates a new SmartDate object.
 SmartDate (DateTime? value)
 Creates a new SmartDate object.
 SmartDate (DateTime? value, bool emptyIsMin)
 Creates a new SmartDate object.
 SmartDate (DateTime? value, EmptyValue emptyValue)
 Creates a new SmartDate object.
 SmartDate (DateTimeOffset value)
 Creates a new SmartDate object.
 SmartDate (DateTimeOffset value, bool emptyIsMin)
 Creates a new SmartDate object.
 SmartDate (DateTimeOffset value, EmptyValue emptyValue)
 Creates a new SmartDate object.
 SmartDate (string? value)
 Creates a new SmartDate object.
 SmartDate (string? value, bool emptyIsMin)
 Creates a new SmartDate object.
 SmartDate (string? value, EmptyValue emptyValue)
 Creates a new SmartDate object.
DateTimeOffset ToDateTimeOffset ()
 Gets the value as a DateTimeOffset.
DateTime? ToNullableDate ()
 Gets the value as a DateTime?.
override string ToString ()
 Returns a text representation of the date value.
string ToString (string? format)
 Returns a text representation of the date value.
override bool Equals (object? obj)
 Compares this object to another SmartDate for equality.
override int GetHashCode ()
 Returns a hash code for this object.
int CompareTo (SmartDate value)
 Compares one SmartDate to another.
int IComparable. CompareTo (object? value)
 Compares one SmartDate to another.
int CompareTo (string? value)
 Compares a SmartDate to a text date value.
int CompareTo (DateTimeOffset value)
 Compares a SmartDate to a date value.
int CompareTo (DateTime value)
 Compares a SmartDate to a date value.
DateTime Add (TimeSpan value)
 Adds a TimeSpan onto the object.
DateTime Subtract (TimeSpan value)
 Subtracts a TimeSpan from the object.
TimeSpan Subtract (DateTimeOffset value)
 Subtracts a DateTimeOffset from the object.
TimeSpan Subtract (DateTime value)
 Subtracts a DateTime from the object.
TypeCode IConvertible. GetTypeCode ()
bool IConvertible. ToBoolean (IFormatProvider? provider)
byte IConvertible. ToByte (IFormatProvider? provider)
char IConvertible. ToChar (IFormatProvider? provider)
DateTime IConvertible. ToDateTime (IFormatProvider? provider)
decimal IConvertible. ToDecimal (IFormatProvider? provider)
double IConvertible. ToDouble (IFormatProvider? provider)
short IConvertible. ToInt16 (IFormatProvider? provider)
int IConvertible. ToInt32 (IFormatProvider? provider)
long IConvertible. ToInt64 (IFormatProvider? provider)
sbyte IConvertible. ToSByte (IFormatProvider? provider)
float IConvertible. ToSingle (IFormatProvider? provider)
string IConvertible. ToString (IFormatProvider? provider)
object IConvertible. ToType (Type conversionType, IFormatProvider? provider)
ushort IConvertible. ToUInt16 (IFormatProvider? provider)
uint IConvertible. ToUInt32 (IFormatProvider? provider)
ulong IConvertible. ToUInt64 (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. The data should be serialized into the SerializationInfo parameter.
void IMobileObject. SetState (SerializationInfo info)
 Method called by MobileFormatter when an object should be deserialized. The data should be deserialized from the SerializationInfo parameter.
void IMobileObject. 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.
void IMobileObject. 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.

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.
static SmartDate Parse (string? value)
 Converts a string value into a SmartDate.
static SmartDate Parse (string? value, EmptyValue emptyValue)
 Converts a string value into a SmartDate.
static SmartDate Parse (string? value, bool emptyIsMin)
 Converts a string value into a SmartDate.
static bool TryParse (string? value, ref SmartDate result)
 Converts a string value into a SmartDate.
static bool TryParse (string? value, EmptyValue emptyValue, ref SmartDate result)
 Converts a string value into a SmartDate.
static DateTime StringToDate (string? value)
 Converts a text date representation into a Date value.
static DateTime StringToDate (string? value, bool emptyIsMin)
 Converts a text date representation into a Date value.
static DateTime StringToDate (string? value, EmptyValue emptyValue)
 Converts a text date representation into a Date value.
static string DateToString (DateTime value, string? formatString)
 Converts a date value into a text representation.
static string DateToString (DateTime value, string? formatString, bool emptyIsMin)
 Converts a date value into a text representation.
static string DateToString (DateTime value, string? formatString, EmptyValue emptyValue)
 Converts a date value into a text representation.
static bool operator== (SmartDate obj1, SmartDate obj2)
 Equality operator.
static bool operator!= (SmartDate obj1, SmartDate obj2)
 Inequality operator.
static implicit operator string (SmartDate obj1)
 Convert a SmartDate to a String.
static implicit operator DateTime (SmartDate obj1)
 Convert a SmartDate to a DateTime.
static implicit operator DateTime? (SmartDate obj1)
 Convert a SmartDate to a nullable DateTime.
static implicit operator DateTimeOffset (SmartDate obj1)
 Convert a SmartDate to a DateTimeOffset.
static operator SmartDate (string dateValue)
 Convert a value to a SmartDate.
static implicit operator SmartDate (DateTime dateValue)
 Convert a value to a SmartDate.
static implicit operator SmartDate (DateTime? dateValue)
 Convert a value to a SmartDate.
static operator SmartDate (DateTimeOffset dateValue)
 Convert a value to a SmartDate.
static bool operator== (SmartDate obj1, DateTime obj2)
 Equality operator.
static bool operator!= (SmartDate obj1, DateTime obj2)
 Inequality operator.
static bool operator== (SmartDate obj1, string obj2)
 Equality operator.
static bool operator!= (SmartDate obj1, string obj2)
 Inequality operator.
static SmartDate operator+ (SmartDate start, TimeSpan span)
 Addition operator.
static SmartDate operator- (SmartDate start, TimeSpan span)
 Subtraction operator.
static TimeSpan operator- (SmartDate start, SmartDate finish)
 Subtraction operator.
static bool operator> (SmartDate obj1, SmartDate obj2)
 Greater than operator.
static bool operator< (SmartDate obj1, SmartDate obj2)
 Less than operator.
static bool operator> (SmartDate obj1, DateTime obj2)
 Greater than operator.
static bool operator< (SmartDate obj1, DateTime obj2)
 Less than operator.
static bool operator> (SmartDate obj1, string obj2)
 Greater than operator.
static bool operator< (SmartDate obj1, string obj2)
 Less than operator.
static bool operator>= (SmartDate obj1, SmartDate obj2)
 Greater than or equals operator.
static bool operator<= (SmartDate obj1, SmartDate obj2)
 Less than or equals operator.
static bool operator>= (SmartDate obj1, DateTime obj2)
 Greater than or equals operator.
static bool operator<= (SmartDate obj1, DateTime obj2)
 Less than or equals operator.
static bool operator>= (SmartDate obj1, string obj2)
 Greater than or equals operator.
static bool operator<= (SmartDate obj1, string obj2)
 Less than or equals operator.

Properties

string FormatString [get, set]
 Gets or sets the format string used to format a date value when it is returned as text.
string Text [get, set]
 Gets or sets the date value.
DateTime Date [get, set]
 Gets or sets the date value.
object DBValue [get]
 Gets a database-friendly version of the date value.
bool IsEmpty [get]
 Gets a value indicating whether this object contains an empty date.
bool EmptyIsMin [get]
 Gets a value indicating whether an empty date is the min or max possible date value.
static ? Func< string?, DateTime?> CustomParser [get, set]
 Gets or sets the custom parser.

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.

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.

Constructor & Destructor Documentation

◆ SmartDate() [1/16]

Csla.SmartDate.SmartDate ( )
inlinestatic

◆ SmartDate() [2/16]

Csla.SmartDate.SmartDate ( bool emptyIsMin)
inline

Creates a new SmartDate object.

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

◆ SmartDate() [3/16]

Csla.SmartDate.SmartDate ( EmptyValue emptyValue)
inline

Creates a new SmartDate object.

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

◆ SmartDate() [4/16]

Csla.SmartDate.SmartDate ( DateTime value)
inline

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.

◆ SmartDate() [5/16]

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

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() [6/16]

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

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() [7/16]

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

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.

◆ SmartDate() [8/16]

Csla.SmartDate.SmartDate ( DateTime? value)
inline

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.

◆ SmartDate() [9/16]

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

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() [10/16]

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

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() [11/16]

Csla.SmartDate.SmartDate ( DateTimeOffset value)
inline

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.

◆ SmartDate() [12/16]

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

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.

◆ SmartDate() [13/16]

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

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.

◆ SmartDate() [14/16]

Csla.SmartDate.SmartDate ( string? value)
inline

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).

◆ SmartDate() [15/16]

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

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.

◆ SmartDate() [16/16]

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

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.

Member Function Documentation

◆ Add()

DateTime Csla.SmartDate.Add ( TimeSpan value)
inline

Adds a TimeSpan onto the object.

Parameters
valueSpan to add to the date.

◆ CompareTo() [1/5]

int Csla.SmartDate.CompareTo ( DateTime value)
inline

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.

◆ CompareTo() [2/5]

int Csla.SmartDate.CompareTo ( DateTimeOffset value)
inline

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.

◆ CompareTo() [3/5]

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

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.

◆ CompareTo() [4/5]

int Csla.SmartDate.CompareTo ( SmartDate value)
inline

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.

◆ CompareTo() [5/5]

int Csla.SmartDate.CompareTo ( string? value)
inline

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.

◆ DateToString() [1/3]

string Csla.SmartDate.DateToString ( DateTime value,
string? formatString )
inlinestatic

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.

◆ DateToString() [2/3]

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

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.

◆ DateToString() [3/3]

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

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.

◆ Equals()

override bool Csla.SmartDate.Equals ( object? obj)
inline

Compares this object to another SmartDate for equality.

Parameters
objObject to compare for equality.

◆ GetChildren()

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

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.

◆ GetHashCode()

override int Csla.SmartDate.GetHashCode ( )
inline

Returns a hash code for this object.

◆ GetState()

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

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.

◆ GetTypeCode()

TypeCode IConvertible. Csla.SmartDate.GetTypeCode ( )
inline

◆ operator DateTime()

implicit Csla.SmartDate.operator DateTime ( SmartDate obj1)
inlinestatic

Convert a SmartDate to a DateTime.

Parameters
obj1SmartDate value.

◆ operator DateTime?()

implicit Csla.SmartDate.operator DateTime? ( SmartDate obj1)
inlinestatic

Convert a SmartDate to a nullable DateTime.

Parameters
obj1SmartDate value.

◆ operator DateTimeOffset()

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

Convert a SmartDate to a DateTimeOffset.

Parameters
obj1SmartDate value.

◆ operator SmartDate() [1/4]

implicit Csla.SmartDate.operator SmartDate ( DateTime dateValue)
inlinestatic

Convert a value to a SmartDate.

Parameters
dateValueValue to convert.

◆ operator SmartDate() [2/4]

implicit Csla.SmartDate.operator SmartDate ( DateTime? dateValue)
inlinestatic

Convert a value to a SmartDate.

Parameters
dateValueValue to convert.

◆ operator SmartDate() [3/4]

Csla.SmartDate.operator SmartDate ( DateTimeOffset dateValue)
inlineexplicitstatic

Convert a value to a SmartDate.

Parameters
dateValueValue to convert.

◆ operator SmartDate() [4/4]

Csla.SmartDate.operator SmartDate ( string dateValue)
inlineexplicitstatic

Convert a value to a SmartDate.

Parameters
dateValueValue to convert.

◆ operator string()

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

Convert a SmartDate to a String.

Parameters
obj1SmartDate value.

◆ operator!=() [1/3]

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

Inequality operator.

Parameters
obj1First object
obj2Second object

◆ operator!=() [2/3]

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

Inequality operator.

Parameters
obj1First object
obj2Second object

◆ operator!=() [3/3]

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

Inequality operator.

Parameters
obj1First object
obj2Second object

◆ operator+()

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

Addition operator.

Parameters
startOriginal date/time
spanSpan to add

◆ operator-() [1/2]

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

Subtraction operator.

Parameters
startOriginal date/time
finishSecond date/time

◆ operator-() [2/2]

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

Subtraction operator.

Parameters
startOriginal date/time
spanSpan to subtract

◆ operator<() [1/3]

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

Less than operator.

Parameters
obj1First object
obj2Second object

◆ operator<() [2/3]

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

Less than operator.

Parameters
obj1First object
obj2Second object

◆ operator<() [3/3]

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

Less than operator.

Parameters
obj1First object
obj2Second object

◆ operator<=() [1/3]

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

Less than or equals operator.

Parameters
obj1First object
obj2Second object

◆ operator<=() [2/3]

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

Less than or equals operator.

Parameters
obj1First object
obj2Second object

◆ operator<=() [3/3]

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

Less than or equals operator.

Parameters
obj1First object
obj2Second object

◆ operator==() [1/3]

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

Equality operator.

Parameters
obj1First object
obj2Second object

◆ operator==() [2/3]

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

Equality operator.

Parameters
obj1First object
obj2Second object

◆ operator==() [3/3]

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

Equality operator.

Parameters
obj1First object
obj2Second object

◆ operator>() [1/3]

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

Greater than operator.

Parameters
obj1First object
obj2Second object

◆ operator>() [2/3]

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

Greater than operator.

Parameters
obj1First object
obj2Second object

◆ operator>() [3/3]

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

Greater than operator.

Parameters
obj1First object
obj2Second object

◆ operator>=() [1/3]

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

Greater than or equals operator.

Parameters
obj1First object
obj2Second object

◆ operator>=() [2/3]

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

Greater than or equals operator.

Parameters
obj1First object
obj2Second object

◆ operator>=() [3/3]

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

Greater than or equals operator.

Parameters
obj1First object
obj2Second object

◆ Parse() [1/3]

SmartDate Csla.SmartDate.Parse ( string? value)
inlinestatic

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.

◆ Parse() [2/3]

SmartDate Csla.SmartDate.Parse ( string? value,
bool emptyIsMin )
inlinestatic

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.

◆ Parse() [3/3]

SmartDate Csla.SmartDate.Parse ( string? value,
EmptyValue emptyValue )
inlinestatic

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.

◆ SetChildren()

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

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.

◆ SetDefaultFormatString()

void Csla.SmartDate.SetDefaultFormatString ( string formatString)
inlinestatic

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.
Exceptions
ArgumentExceptionformatString is null, string.Empty or only consists of white spaces.

◆ SetState()

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

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.

◆ StringToDate() [1/3]

DateTime Csla.SmartDate.StringToDate ( string? value)
inlinestatic

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.

◆ StringToDate() [2/3]

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

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.

◆ StringToDate() [3/3]

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

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.

◆ Subtract() [1/3]

TimeSpan Csla.SmartDate.Subtract ( DateTime value)
inline

Subtracts a DateTime from the object.

Parameters
valueDate to subtract from the date.

◆ Subtract() [2/3]

TimeSpan Csla.SmartDate.Subtract ( DateTimeOffset value)
inline

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.

◆ Subtract() [3/3]

DateTime Csla.SmartDate.Subtract ( TimeSpan value)
inline

Subtracts a TimeSpan from the object.

Parameters
valueSpan to subtract from the date.

◆ ToBoolean()

bool IConvertible. Csla.SmartDate.ToBoolean ( IFormatProvider? provider)
inline

◆ ToByte()

byte IConvertible. Csla.SmartDate.ToByte ( IFormatProvider? provider)
inline

◆ ToChar()

char IConvertible. Csla.SmartDate.ToChar ( IFormatProvider? provider)
inline

◆ ToDateTime()

DateTime IConvertible. Csla.SmartDate.ToDateTime ( IFormatProvider? provider)
inline

◆ ToDateTimeOffset()

DateTimeOffset Csla.SmartDate.ToDateTimeOffset ( )
inline

Gets the value as a DateTimeOffset.

◆ ToDecimal()

decimal IConvertible. Csla.SmartDate.ToDecimal ( IFormatProvider? provider)
inline

◆ ToDouble()

double IConvertible. Csla.SmartDate.ToDouble ( IFormatProvider? provider)
inline

◆ ToInt16()

short IConvertible. Csla.SmartDate.ToInt16 ( IFormatProvider? provider)
inline

◆ ToInt32()

int IConvertible. Csla.SmartDate.ToInt32 ( IFormatProvider? provider)
inline

◆ ToInt64()

long IConvertible. Csla.SmartDate.ToInt64 ( IFormatProvider? provider)
inline

◆ ToNullableDate()

DateTime? Csla.SmartDate.ToNullableDate ( )
inline

Gets the value as a DateTime?.

◆ ToSByte()

sbyte IConvertible. Csla.SmartDate.ToSByte ( IFormatProvider? provider)
inline

◆ ToSingle()

float IConvertible. Csla.SmartDate.ToSingle ( IFormatProvider? provider)
inline

◆ ToString() [1/4]

override string Csla.SmartDate.ToString ( )
inline

Returns a text representation of the date value.

◆ ToString() [2/4]

string IConvertible. Csla.SmartDate.ToString ( IFormatProvider? provider)
inline

◆ ToString() [3/4]

string Csla.SmartDate.ToString ( string? format)
inline

Returns a text representation of the date value.

Parameters
formatA standard .NET format string.

◆ ToString() [4/4]

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

◆ ToType()

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

◆ ToUInt16()

ushort IConvertible. Csla.SmartDate.ToUInt16 ( IFormatProvider? provider)
inline

◆ ToUInt32()

uint IConvertible. Csla.SmartDate.ToUInt32 ( IFormatProvider? provider)
inline

◆ ToUInt64()

ulong IConvertible. Csla.SmartDate.ToUInt64 ( IFormatProvider? provider)
inline

◆ TryParse() [1/2]

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

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.

◆ TryParse() [2/2]

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

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.

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.

◆ Date

DateTime Csla.SmartDate.Date
getset

Gets or sets the date value.

◆ 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.

◆ 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.

◆ 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.

◆ IsEmpty

bool Csla.SmartDate.IsEmpty
get

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

Implements Csla.Core.ISmartField.

◆ 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).

Implements Csla.Core.ISmartField.


The documentation for this struct was generated from the following file: