''' <summary> ''' Initializes a new instance of the <see cref="DateTimeNull" /> class to a specified number of ticks. ''' </summary> ''' <param name="ticks">The ticks.</param> Public Sub New(ByVal ticks As Long) MyBase.New() Me.InternalDate = New System.DateTime(ticks) End Sub
''' <summary> ''' Initializes a new instance of the <see cref="DateTimeNull" /> class using the specified System.DateTime value. ''' </summary> ''' <param name="value">The value.</param> Public Sub New(ByVal value As System.DateTime) Me.New(value.Ticks) End Sub
''' <summary> ''' Initializes a new instance of the <see cref="DateTimeNull" /> class using the specified System.Data.SqlTypes.SqlDateTime value. ''' </summary> ''' <param name="value">The value.</param> Public Sub New(ByVal value As System.Data.SqlTypes.SqlDateTime) MyBase.New() Dim dt As System.DateTime dt = Convert.ToDateTime(value) Me.InternalDate = dt End Sub
''' <summary> ''' Initializes a new instance of the <see cref="DateTimeNull" /> class using a system.DBNull object. ''' </summary> ''' <param name="value">The value.</param> Public Sub New(ByVal value As System.DBNull) Me.New(System.DateTime.MinValue) If Not Me.IsNull Then Me.SetIsNull(True) End If End Sub
''' <summary> ''' Gets the date component of this instance. ''' </summary> ''' <value>A new DateTime with the same date as this instance, and the time value set to 12:00:00 midnight (00:00:00).</value> ''' <exception cref="ArgumentNullException">Thrown</exception> Public ReadOnly Property [Date]() As DateTimeNull Get If Me.HasValue Then Return New DateTimeNull(Me.InternalDate.Date) Else Throw New ArgumentNullException("Date cannot be returned for a null DateTimeNull") End If End Get End Property ''' <summary> ''' Gets the day of the month represented by this instance. ''' </summary> ''' <remarks>The day component, expressed as a value between 1 and 31.</remarks> Public ReadOnly Property Day() As System.Int32 Get If Me.HasValue Then Return Me.InternalDate.Day Else Throw New NullReferenceException("Day cannot be expressed for a null DateTimeNull object. ") End If End Get End Property ''' <summary> ''' Gets the hour component of the date represented by this instance. ''' </summary> ''' <returns>The hour component, expressed as a value between 0 and 23, inclusive.</returns> Public ReadOnly Property Hour() As System.Int32 Get If Me.HasValue Then Return Me.InternalDate.Hour Else Throw New NullReferenceException("Hour cannot be expressed for a null DateTimeNull object. ") End If End Get End Property ''' <summary> ''' Gets a System.DateTime object that is set to the current date and time on this computer, expressed as the local time. ''' </summary> ''' <returns>A DateTime whose value is the current local date and time.</returns> Public Shared ReadOnly Property Now() As DateTime Get Return DateTime.UtcNow.ToLocalTime End Get End Property ''' <summary> ''' Gets the current date. ''' </summary> '''<returns>A DateTime set to today's date, with the time component set to 00:00:00.</returns> Public Shared ReadOnly Property Today() As DateTime Get Return DateTime.Now.Date End Get End Property
Remember Me
a@href@title, b, blockquote@cite, em, i, strike, strong, sub, sup, u
Disclaimer The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.