![]() |
CSLA .NET 10.0.0
A home for your business logic
|
Provides a date data type that understands the concept of an empty date value. More...
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. | |
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.
|
inlinestatic |
|
inline |
Creates a new SmartDate object.
| emptyIsMin | Indicates whether an empty date is the min or max date value. |
|
inline |
Creates a new SmartDate object.
| emptyValue | Indicates whether an empty date is the min or max date value. |
|
inline |
|
inline |
Creates a new SmartDate object.
| value | The initial value of the object. |
| emptyIsMin | Indicates whether an empty date is the min or max date value. |
|
inline |
Creates a new SmartDate object.
| value | The initial value of the object. |
| emptyValue | Indicates whether an empty date is the min or max date value. |
|
inline |
Creates a new SmartDate object.
| value | The initial value of the object. |
| emptyValue | Indicates whether an empty date is the min or max date value. |
| kind | One of the DateTimeKind values. |
|
inline |
|
inline |
Creates a new SmartDate object.
| value | The initial value of the object. |
| emptyIsMin | Indicates whether an empty date is the min or max date value. |
|
inline |
Creates a new SmartDate object.
| value | The initial value of the object. |
| emptyValue | Indicates whether an empty date is the min or max date 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.
| value | The initial value of the object. |
|
inline |
Creates a new SmartDate object.
| value | The initial value of the object. |
| emptyIsMin | Indicates 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.
|
inline |
Creates a new SmartDate object.
| value | The initial value of the object. |
| emptyValue | Indicates 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.
|
inline |
|
inline |
Creates a new SmartDate object.
| value | The initial value of the object (as text). |
| emptyIsMin | Indicates whether an empty date is the min or max date value. |
|
inline |
Creates a new SmartDate object.
| value | The initial value of the object (as text). |
| emptyValue | Indicates whether an empty date is the min or max date value. |
|
inline |
Adds a TimeSpan onto the object.
| value | Span to add to the date. |
|
inline |
Compares a SmartDate to a date value.
| value | The date to which we are being compared. |
|
inline |
Compares a SmartDate to a date value.
| value | The date to which we are being compared. |
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.
|
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.
| value | The date to which we are being compared. |
|
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.
| value | The date to which we are being compared. |
|
inline |
Compares a SmartDate to a text date value.
| value | The date to which we are being compared. |
|
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.
| value | The date value to convert. |
| formatString | The format string used to format the date into text. |
|
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.
| value | The date value to convert. |
| formatString | The format string used to format the date into text. |
| emptyIsMin | Indicates whether an empty date is the min or max date value. |
|
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.
| value | The date value to convert. |
| formatString | The format string used to format the date into text. |
| emptyValue | Indicates whether an empty date is the min or max date value. |
|
inline |
Compares this object to another SmartDate for equality.
| obj | Object to compare for equality. |
|
inline |
Method called by MobileFormatter when an object should serialize its child references. The data should be serialized into the SerializationInfo parameter.
| info | Object to contain the serialized data. |
| formatter | Reference to the formatter performing the serialization. |
Implements Csla.Serialization.Mobile.IMobileObject.
|
inline |
Returns a hash code for this object.
|
inline |
Method called by MobileFormatter when an object should serialize its data. The data should be serialized into the SerializationInfo parameter.
| info | Object to contain the serialized data. |
Implements Csla.Serialization.Mobile.IMobileObject.
|
inline |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
Convert a value to a SmartDate.
| dateValue | Value to convert. |
|
inlinestatic |
Convert a value to a SmartDate.
| dateValue | Value to convert. |
|
inlineexplicitstatic |
Convert a value to a SmartDate.
| dateValue | Value to convert. |
|
inlineexplicitstatic |
Convert a value to a SmartDate.
| dateValue | Value to convert. |
|
inlinestatic |
|
inlinestatic |
Inequality operator.
| obj1 | First object |
| obj2 | Second object |
Inequality operator.
| obj1 | First object |
| obj2 | Second object |
|
inlinestatic |
Inequality operator.
| obj1 | First object |
| obj2 | Second object |
Addition operator.
| start | Original date/time |
| span | Span to add |
Subtraction operator.
| start | Original date/time |
| finish | Second date/time |
Subtraction operator.
| start | Original date/time |
| span | Span to subtract |
|
inlinestatic |
Less than operator.
| obj1 | First object |
| obj2 | Second object |
Less than operator.
| obj1 | First object |
| obj2 | Second object |
|
inlinestatic |
Less than operator.
| obj1 | First object |
| obj2 | Second object |
|
inlinestatic |
Less than or equals operator.
| obj1 | First object |
| obj2 | Second object |
Less than or equals operator.
| obj1 | First object |
| obj2 | Second object |
|
inlinestatic |
Less than or equals operator.
| obj1 | First object |
| obj2 | Second object |
|
inlinestatic |
Equality operator.
| obj1 | First object |
| obj2 | Second object |
Equality operator.
| obj1 | First object |
| obj2 | Second object |
|
inlinestatic |
Equality operator.
| obj1 | First object |
| obj2 | Second object |
|
inlinestatic |
Greater than operator.
| obj1 | First object |
| obj2 | Second object |
Greater than operator.
| obj1 | First object |
| obj2 | Second object |
|
inlinestatic |
Greater than operator.
| obj1 | First object |
| obj2 | Second object |
|
inlinestatic |
Greater than or equals operator.
| obj1 | First object |
| obj2 | Second object |
Greater than or equals operator.
| obj1 | First object |
| obj2 | Second object |
|
inlinestatic |
Greater than or equals operator.
| obj1 | First object |
| obj2 | Second object |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
|
inline |
Method called by MobileFormatter when an object should deserialize its child references. The data should be deserialized from the SerializationInfo parameter.
| info | Object containing the serialized data. |
| formatter | Reference to the formatter performing the deserialization. |
Implements Csla.Serialization.Mobile.IMobileObject.
|
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.
| formatString | The format string should follow the requirements for the .NET System.String.Format statement. |
| ArgumentException | formatString is null, string.Empty or only consists of white spaces. |
|
inline |
Method called by MobileFormatter when an object should be deserialized. The data should be deserialized from the SerializationInfo parameter.
| info | Object containing the serialized data. |
Implements Csla.Serialization.Mobile.IMobileObject.
|
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.
| value | The text representation of the date. |
|
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.
| value | The text representation of the date. |
| emptyIsMin | Indicates whether an empty date is the min or max date 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 or MaxValue of the Date datatype depending on the EmptyIsMin parameter.
| value | The text representation of the date. |
| emptyValue | Indicates whether an empty date is the min or max date value. |
|
inline |
Subtracts a DateTime from the object.
| value | Date to subtract from the date. |
|
inline |
Subtracts a DateTimeOffset from the object.
| value | DateTimeOffset 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.
|
inline |
Subtracts a TimeSpan from the object.
| value | Span to subtract from the date. |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Gets the value as a DateTimeOffset.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Gets the value as a DateTime?.
|
inline |
|
inline |
|
inline |
Returns a text representation of the date value.
|
inline |
|
inline |
Returns a text representation of the date value.
| format | A standard .NET format string. |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inlinestatic |
|
inlinestatic |
|
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.
|
getset |
Gets or sets the date value.
|
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.
|
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.
|
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.
|
get |
Gets a value indicating whether this object contains an empty date.
Implements Csla.Core.ISmartField.
|
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.