Versión Copiada del tfs
This commit is contained in:
65
Extensiones/DateOnlyExtensions.vb
Normal file
65
Extensiones/DateOnlyExtensions.vb
Normal file
@@ -0,0 +1,65 @@
|
||||
Imports System.Runtime.CompilerServices
|
||||
|
||||
Namespace Extensiones
|
||||
Public Module DateOnlyExtensions
|
||||
<Extension()>
|
||||
Public Function Minimo(Fecha1 As Nullable(Of DateOnly), Fecha2 As Nullable(Of DateOnly)) As Nullable(Of DateOnly)
|
||||
Dim t1, t2 As DateOnly
|
||||
If Fecha1.HasValue Then t1 = Fecha1.Value
|
||||
If Fecha2.HasValue Then t2 = Fecha2.Value
|
||||
If t1 < t2 Then
|
||||
Return Fecha1
|
||||
Else
|
||||
Return Fecha2
|
||||
End If
|
||||
End Function
|
||||
|
||||
<Extension()>
|
||||
Public Function Maximo(Fecha1 As Nullable(Of DateOnly), Fecha2 As Nullable(Of DateOnly)) As Nullable(Of DateOnly)
|
||||
Dim t1, t2 As DateOnly
|
||||
If Fecha1.HasValue Then t1 = Fecha1.Value
|
||||
If Fecha2.HasValue Then t2 = Fecha2.Value
|
||||
If t1 > t2 Then
|
||||
Return Fecha1
|
||||
Else
|
||||
Return Fecha2
|
||||
End If
|
||||
End Function
|
||||
|
||||
<Extension()>
|
||||
Public Function ValorNumerico(Fecha As Nullable(Of DateOnly)) As Long
|
||||
If Fecha Is Nothing Then
|
||||
Return 0
|
||||
Else
|
||||
Return Fecha.Value.Year * 10000 + Fecha.Value.Month * 100 + Fecha.Value.Day
|
||||
End If
|
||||
End Function
|
||||
|
||||
<Extension()>
|
||||
Public Function ToDateTime(Fecha As Nullable(Of DateOnly)) As DateTime
|
||||
If Fecha Is Nothing Then
|
||||
Return Nothing
|
||||
Else
|
||||
Return New DateTime(Fecha.Value.Year, Fecha.Value.Month, Fecha.Value.Day)
|
||||
End If
|
||||
End Function
|
||||
<Extension()>
|
||||
Public Function ToDateTime(Fecha As DateOnly) As DateTime
|
||||
Return New DateTime(Fecha.Year, Fecha.Month, Fecha.Day)
|
||||
End Function
|
||||
|
||||
<Extension()>
|
||||
Public Function ToDate(Fecha As Nullable(Of DateOnly)) As DateTime
|
||||
If Fecha Is Nothing Then
|
||||
Return Nothing
|
||||
Else
|
||||
Return New Date(Fecha.Value.Year, Fecha.Value.Month, Fecha.Value.Day)
|
||||
End If
|
||||
End Function
|
||||
<Extension()>
|
||||
Public Function ToDate(Fecha As DateOnly) As DateTime
|
||||
Return New Date(Fecha.Year, Fecha.Month, Fecha.Day)
|
||||
End Function
|
||||
|
||||
End Module
|
||||
End Namespace
|
||||
Reference in New Issue
Block a user